@@ -330,7 +330,7 @@ object Parsers {
330330 else if in.token == END then
331331 if endSeen then syntaxError(" duplicate end marker" )
332332 checkEndMarker(stats)
333- recur(sepSeen, true )
333+ recur(sepSeen, endSeen = true )
334334 else if isStatSeqEnd || in.token == altEnd then
335335 false
336336 else if sepSeen || endSeen then
@@ -663,7 +663,6 @@ object Parsers {
663663 def closingOffset (lineStart : Offset ): Offset =
664664 if in.lineOffset >= 0 && lineStart >= in.lineOffset then in.lineOffset
665665 else
666- val candidate = source.nextLine(lineStart) // unused
667666 val commentStart = skipBlanks(lineStart)
668667 if testChar(commentStart, '/' ) && indentWidth < in.indentWidth(commentStart)
669668 then closingOffset(source.nextLine(lineStart))
@@ -1297,6 +1296,8 @@ object Parsers {
12971296 case _ : (ForYield | ForDo ) => in.token == FOR
12981297 case _ => false
12991298
1299+ def endName = if in.token == IDENTIFIER then in.name.toString else tokenString(in.token)
1300+
13001301 def matchesAndSetEnd (last : T ): Boolean =
13011302 val didMatch = matches(last)
13021303 if didMatch then
@@ -1307,6 +1308,9 @@ object Parsers {
13071308 val start = in.skipToken()
13081309 if stats.isEmpty || ! matchesAndSetEnd(stats.last) then
13091310 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" )
13101314 in.token = IDENTIFIER // Leaving it as the original token can confuse newline insertion
13111315 in.nextToken()
13121316 end checkEndMarker
@@ -3846,9 +3850,9 @@ object Parsers {
38463850 def templateStatSeq (): (ValDef , List [Tree ]) = checkNoEscapingPlaceholders {
38473851 var self : ValDef = EmptyValDef
38483852 val stats = new ListBuffer [Tree ]
3849- if ( isExprIntro && ! isDefIntro(modifierTokens)) {
3853+ if isExprIntro && ! isDefIntro(modifierTokens) then
38503854 val first = expr1()
3851- if ( in.token == ARROW ) {
3855+ if in.token == ARROW then
38523856 first match {
38533857 case Typed (tree @ This (EmptyTypeIdent ), tpt) =>
38543858 self = makeSelfDef(nme.WILDCARD , tpt).withSpan(first.span)
@@ -3859,11 +3863,10 @@ object Parsers {
38593863 }
38603864 in.token = SELFARROW // suppresses INDENT insertion after `=>`
38613865 in.nextToken()
3862- }
38633866 else
38643867 stats += first
38653868 statSepOrEnd(stats)
3866- }
3869+ end if
38673870 while
38683871 var empty = false
38693872 if (in.token == IMPORT )
@@ -3880,7 +3883,7 @@ object Parsers {
38803883 empty = true
38813884 statSepOrEnd(stats, empty)
38823885 do ()
3883- (self, if ( stats.isEmpty) List (EmptyTree ) else stats.toList)
3886+ (self, if stats.isEmpty then List (EmptyTree ) else stats.toList)
38843887 }
38853888
38863889 /** RefineStatSeq ::= RefineStat {semi RefineStat}
0 commit comments