From 2072eba01ab67eed3aa4f0368510a88b00f65690 Mon Sep 17 00:00:00 2001 From: Matt Bovel Date: Wed, 21 May 2025 09:46:15 +0000 Subject: [PATCH] Fix incorrect warning with -no-indent --- compiler/src/dotty/tools/dotc/parsing/Parsers.scala | 2 +- tests/pos/i21749.scala | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i21749.scala 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 + } +}