diff --git a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala index bc46ebd4b606..9968bdeb831f 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala @@ -747,8 +747,8 @@ object Scanners { case _ => false currentRegion match case r: Indented if isEnclosedInParens(r.outer) => - // For some region prefixes (COLONeol, EQUALS) only OUTDENT if COMMA at EOL - if canStartIndentTokens.contains(r.prefix) && !statCtdTokens.contains(r.prefix) then + // For region prefix COLONeol, only OUTDENT if COMMA at EOL + if r.prefix == COLONeol then val lookahead = LookaheadScanner() lookahead.nextToken() if lookahead.isAfterLineEnd then diff --git a/tests/neg/i22527.scala b/tests/neg/i22527.scala index b9d9166e8fc2..4b80c21ff035 100644 --- a/tests/neg/i22527.scala +++ b/tests/neg/i22527.scala @@ -6,12 +6,6 @@ def test: Unit = true, "ok" // error end of statement expected but ',' found ) -def toss: Unit = - assert( - throw - null, "ok" // error same - ) - def callme[A](x: => A, msg: String) = try x.toString catch case t: RuntimeException => msg // not all indented regions require COMMA at EOL for OUTDENT @@ -22,3 +16,10 @@ def orElse(x: Int): Unit = true // error ',' or ')' expected, but 'true' found else false, "fail") + +def g: Unit = + identity( + x = + class X extends AnyRef, Serializable // error + 27 // error + ) diff --git a/tests/pos/i22527.scala b/tests/pos/i22527.scala index 055ed8acfae2..d222c3311b86 100644 --- a/tests/pos/i22527.scala +++ b/tests/pos/i22527.scala @@ -6,13 +6,6 @@ def f: Unit = 42 ) -def g: Unit = - identity( - x = - class X extends AnyRef, Serializable - 27 - ) - def test: Unit = assert( identity: @@ -26,6 +19,11 @@ def toss: Unit = null, "ok" ) +def raise: Unit = + assert( + throw + null, "ok" // ok now + ) def callme[A](x: => A, msg: String) = try x.toString catch case t: RuntimeException => msg @@ -63,3 +61,12 @@ def k(xs: List[Int], y: Int, z: Int) = z, ) ) + +object `arrow eol`: + def f(g: Int => Int, i: Int): Int = g(i) + def g(map: Int => Int): Int => Int = map + def test = + f( + g: x => + x + 1, 42 + )