diff --git a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala index 2007b633a7c5..68c43dc52189 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala @@ -617,6 +617,7 @@ object Scanners { if nextWidth < lastWidth then currentRegion = topLevelRegion(nextWidth) else if !isLeadingInfixOperator(nextWidth) && !statCtdTokens.contains(lastToken) && lastToken != INDENT then currentRegion match + case _ if token == EOF => // no OUTDENT at EOF case r: Indented => insert(OUTDENT, offset) handleNewIndentWidth(r.enclosing, ir => diff --git a/tests/pos/i22332.scala b/tests/pos/i22332.scala new file mode 100644 index 000000000000..1b0b6a370329 --- /dev/null +++ b/tests/pos/i22332.scala @@ -0,0 +1,5 @@ + +object Foo: + val foo = 42 + // one space + \ No newline at end of file