Skip to content

Commit eb2c406

Browse files
committed
Preserve EOF token when probing arrow EOL
1 parent d7d893d commit eb2c406

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

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

+6-3
Original file line numberDiff line numberDiff line change
@@ -682,13 +682,16 @@ object Scanners {
682682
reset()
683683
if atEOL then token = COLONeol
684684

685-
// consume => and insert <indent> if applicable
685+
// consume => and insert <indent> if applicable. Used to detect colon arrow: x =>
686686
def observeArrowIndented(): Unit =
687687
if isArrow && indentSyntax then
688688
peekAhead()
689-
val atEOL = isAfterLineEnd || token == EOF
689+
val atEOL = isAfterLineEnd
690+
val atEOF = token == EOF
690691
reset()
691-
if atEOL then
692+
if atEOF then
693+
token = EOF
694+
else if atEOL then
692695
val nextWidth = indentWidth(next.offset)
693696
val lastWidth = currentRegion.indentWidth
694697
if lastWidth < nextWidth then

0 commit comments

Comments
 (0)