diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 9c081c8d21af..f7687ec6c79d 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -721,7 +721,7 @@ object Parsers { def checkNextNotIndented(): Unit = if in.isNewLine then val nextIndentWidth = in.indentWidth(in.next.offset) - if in.currentRegion.indentWidth < nextIndentWidth then + if in.currentRegion.indentWidth < nextIndentWidth && in.currentRegion.closedBy == OUTDENT then warning(em"Line is indented too far to the right, or a `{` or `:` is missing", in.next.offset) /* -------- REWRITES ----------------------------------------------------------- */ diff --git a/tests/pos/i21749.scala b/tests/pos/i21749.scala new file mode 100644 index 000000000000..6180b629f06b --- /dev/null +++ b/tests/pos/i21749.scala @@ -0,0 +1,9 @@ +//> using options -Xfatal-warnings -no-indent + +object Test { + 1 match { + case 1 => + case class Test(name: String) + Nil + } +}