diff --git a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala index 0fa71dd02a8b..1a2f3cd3d86a 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala @@ -539,7 +539,7 @@ object Scanners { || nextWidth == lastWidth && (indentPrefix == MATCH || indentPrefix == CATCH) && token != CASE then if currentRegion.isOutermost then if nextWidth < lastWidth then currentRegion = topLevelRegion(nextWidth) - else if !isLeadingInfixOperator(nextWidth) && !statCtdTokens.contains(lastToken) then + else if !isLeadingInfixOperator(nextWidth) && !statCtdTokens.contains(lastToken) && lastToken != INDENT then currentRegion match case r: Indented => currentRegion = r.enclosing diff --git a/tests/pos/i14061.scala b/tests/pos/i14061.scala new file mode 100644 index 000000000000..1431c1248255 --- /dev/null +++ b/tests/pos/i14061.scala @@ -0,0 +1,10 @@ +def main(args: Array[String]): Unit = + val bar: PartialFunction[Throwable, Unit] = + case e: IllegalArgumentException => e.printStackTrace + case e: Throwable => e.printStackTrace + try + println("a") + catch + bar + finally + println("a") \ No newline at end of file