diff --git a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala index d977b084a14d..5da8db6a91c8 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala @@ -601,7 +601,9 @@ object Scanners { case r: Indented if !r.isOutermost && closingRegionTokens.contains(token) - && !(token == CASE && r.prefix == MATCH) => + && !(token == CASE && r.prefix == MATCH) + && next.token == EMPTY // can be violated for ill-formed programs, e.g. neg/i12605.sala + => currentRegion = r.enclosing insert(OUTDENT, offset) case _ => diff --git a/tests/neg/i12605.scala b/tests/neg/i12605.scala new file mode 100644 index 000000000000..bcd7aedc606b --- /dev/null +++ b/tests/neg/i12605.scala @@ -0,0 +1,4 @@ +object Foo: + def joe(): List[(Int, Int)] = + List((2, 3), (3, 4)).filter case (a, b) => b > a // error // error +// error \ No newline at end of file