Skip to content

Commit a575d18

Browse files
committed
Drop lastOffset
1 parent aadc10f commit a575d18

File tree

2 files changed

+5
-24
lines changed

2 files changed

+5
-24
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,6 @@ object Parsers {
233233

234234
/* ------------- ERROR HANDLING ------------------------------------------- */
235235

236-
/** The offset of the last time when a statement on a new line was definitely
237-
* encountered in the current scope or an outer scope.
238-
*/
239-
private var lastStatOffset = -1
240-
241-
def setLastStatOffset(): Unit =
242-
if (mustStartStat && in.isAfterLineEnd)
243-
lastStatOffset = in.offset
244-
245236
/** Is offset1 less or equally indented than offset2?
246237
* This is the case if the characters between the preceding end-of-line and offset1
247238
* are a prefix of the characters between the preceding end-of-line and offset2.
@@ -533,11 +524,8 @@ object Parsers {
533524
if (in.rewriteToIndent) bracesToIndented(body, rewriteWithColon)
534525
else inBraces(body)
535526

536-
def inDefScopeBraces[T](body: => T, rewriteWithColon: Boolean = false): T = {
537-
val saved = lastStatOffset
538-
try inBracesOrIndented(body, rewriteWithColon)
539-
finally lastStatOffset = saved
540-
}
527+
def inDefScopeBraces[T](body: => T, rewriteWithColon: Boolean = false): T =
528+
inBracesOrIndented(body, rewriteWithColon)
541529

542530
/** part { `separator` part }
543531
*/
@@ -1538,10 +1526,7 @@ object Parsers {
15381526
else t
15391527

15401528
/** The block in a quote or splice */
1541-
def stagedBlock() =
1542-
val saved = lastStatOffset
1543-
try inBraces(block(simplify = true))
1544-
finally lastStatOffset = saved
1529+
def stagedBlock() = inBraces(block(simplify = true))
15451530

15461531
/** SimpleEpxr ::= spliceId | ‘$’ ‘{’ Block ‘}’)
15471532
* SimpleType ::= spliceId | ‘$’ ‘{’ Block ‘}’)
@@ -3642,7 +3627,6 @@ object Parsers {
36423627
val meths = new ListBuffer[DefDef]
36433628
val exitOnError = false
36443629
while !isStatSeqEnd && !exitOnError do
3645-
setLastStatOffset()
36463630
meths += extMethod(numLeadParams)
36473631
acceptStatSepUnlessAtEnd(meths)
36483632
if meths.isEmpty then syntaxError("`def` expected")
@@ -3781,7 +3765,6 @@ object Parsers {
37813765
def topStatSeq(outermost: Boolean = false): List[Tree] = {
37823766
val stats = new ListBuffer[Tree]
37833767
while (!isStatSeqEnd) {
3784-
setLastStatOffset()
37853768
if (in.token == PACKAGE) {
37863769
val start = in.skipToken()
37873770
if (in.token == OBJECT) {
@@ -3843,7 +3826,6 @@ object Parsers {
38433826
}
38443827
var exitOnError = false
38453828
while (!isStatSeqEnd && !exitOnError) {
3846-
setLastStatOffset()
38473829
if (in.token == IMPORT)
38483830
stats ++= importClause(IMPORT, mkImport())
38493831
else if (in.token == EXPORT)
@@ -3923,7 +3905,6 @@ object Parsers {
39233905
val stats = new ListBuffer[Tree]
39243906
var exitOnError = false
39253907
while (!isStatSeqEnd && in.token != CASE && !exitOnError) {
3926-
setLastStatOffset()
39273908
if (in.token == IMPORT)
39283909
stats ++= importClause(IMPORT, mkImport())
39293910
else if (isExprIntro)

tasty/test/dotty/tools/tasty/TastyHeaderUnpicklerTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ object TastyHeaderUnpicklerTest {
5757
buf.writeNat(exp)
5858
buf.writeNat(compilerBytes.length)
5959
buf.writeBytes(compilerBytes, compilerBytes.length)
60-
buf.writeUncompressedLong(237478l)
61-
buf.writeUncompressedLong(324789l)
60+
buf.writeUncompressedLong(237478L)
61+
buf.writeUncompressedLong(324789L)
6262
buf
6363
}
6464

0 commit comments

Comments
 (0)