@@ -330,7 +330,7 @@ object Parsers {
330
330
else if in.token == END then
331
331
if endSeen then syntaxError(" duplicate end marker" )
332
332
checkEndMarker(stats)
333
- recur(sepSeen, true )
333
+ recur(sepSeen, endSeen = true )
334
334
else if isStatSeqEnd || in.token == altEnd then
335
335
false
336
336
else if sepSeen || endSeen then
@@ -663,7 +663,6 @@ object Parsers {
663
663
def closingOffset (lineStart : Offset ): Offset =
664
664
if in.lineOffset >= 0 && lineStart >= in.lineOffset then in.lineOffset
665
665
else
666
- val candidate = source.nextLine(lineStart) // unused
667
666
val commentStart = skipBlanks(lineStart)
668
667
if testChar(commentStart, '/' ) && indentWidth < in.indentWidth(commentStart)
669
668
then closingOffset(source.nextLine(lineStart))
@@ -1297,6 +1296,8 @@ object Parsers {
1297
1296
case _ : (ForYield | ForDo ) => in.token == FOR
1298
1297
case _ => false
1299
1298
1299
+ def endName = if in.token == IDENTIFIER then in.name.toString else tokenString(in.token)
1300
+
1300
1301
def matchesAndSetEnd (last : T ): Boolean =
1301
1302
val didMatch = matches(last)
1302
1303
if didMatch then
@@ -1307,6 +1308,9 @@ object Parsers {
1307
1308
val start = in.skipToken()
1308
1309
if stats.isEmpty || ! matchesAndSetEnd(stats.last) then
1309
1310
syntaxError(" misaligned end marker" , Span (start, in.lastCharOffset))
1311
+ else if overlapsPatch(source, Span (start, start)) then
1312
+ patch(source, Span (start, start), " " )
1313
+ patch(source, Span (start, in.lastCharOffset), s " } // end $endName" )
1310
1314
in.token = IDENTIFIER // Leaving it as the original token can confuse newline insertion
1311
1315
in.nextToken()
1312
1316
end checkEndMarker
@@ -3846,9 +3850,9 @@ object Parsers {
3846
3850
def templateStatSeq (): (ValDef , List [Tree ]) = checkNoEscapingPlaceholders {
3847
3851
var self : ValDef = EmptyValDef
3848
3852
val stats = new ListBuffer [Tree ]
3849
- if ( isExprIntro && ! isDefIntro(modifierTokens)) {
3853
+ if isExprIntro && ! isDefIntro(modifierTokens) then
3850
3854
val first = expr1()
3851
- if ( in.token == ARROW ) {
3855
+ if in.token == ARROW then
3852
3856
first match {
3853
3857
case Typed (tree @ This (EmptyTypeIdent ), tpt) =>
3854
3858
self = makeSelfDef(nme.WILDCARD , tpt).withSpan(first.span)
@@ -3859,11 +3863,10 @@ object Parsers {
3859
3863
}
3860
3864
in.token = SELFARROW // suppresses INDENT insertion after `=>`
3861
3865
in.nextToken()
3862
- }
3863
3866
else
3864
3867
stats += first
3865
3868
statSepOrEnd(stats)
3866
- }
3869
+ end if
3867
3870
while
3868
3871
var empty = false
3869
3872
if (in.token == IMPORT )
@@ -3880,7 +3883,7 @@ object Parsers {
3880
3883
empty = true
3881
3884
statSepOrEnd(stats, empty)
3882
3885
do ()
3883
- (self, if ( stats.isEmpty) List (EmptyTree ) else stats.toList)
3886
+ (self, if stats.isEmpty then List (EmptyTree ) else stats.toList)
3884
3887
}
3885
3888
3886
3889
/** RefineStatSeq ::= RefineStat {semi RefineStat}
0 commit comments