Skip to content

Commit 959e153

Browse files
committed
Relax and restrict only colon regions
1 parent 77dde82 commit 959e153

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

compiler/src/dotty/tools/dotc/parsing/Scanners.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -747,8 +747,8 @@ object Scanners {
747747
case _ => false
748748
currentRegion match
749749
case r: Indented if isEnclosedInParens(r.outer) =>
750-
// For some region prefixes (COLONeol, EQUALS) only OUTDENT if COMMA at EOL
751-
if canStartIndentTokens.contains(r.prefix) && !statCtdTokens.contains(r.prefix) then
750+
// For region prefix COLONeol, only OUTDENT if COMMA at EOL
751+
if r.prefix == COLONeol then
752752
val lookahead = LookaheadScanner()
753753
lookahead.nextToken()
754754
if lookahead.isAfterLineEnd then

tests/neg/i22527.scala

+7-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ def test: Unit =
66
true, "ok" // error end of statement expected but ',' found
77
)
88

9-
def toss: Unit =
10-
assert(
11-
throw
12-
null, "ok" // error same
13-
)
14-
159
def callme[A](x: => A, msg: String) = try x.toString catch case t: RuntimeException => msg
1610

1711
// not all indented regions require COMMA at EOL for OUTDENT
@@ -22,3 +16,10 @@ def orElse(x: Int): Unit =
2216
true // error ',' or ')' expected, but 'true' found
2317
else
2418
false, "fail")
19+
20+
def g: Unit =
21+
identity(
22+
x =
23+
class X extends AnyRef, Serializable // error
24+
27 // error
25+
)

tests/pos/i22527.scala

+14-7
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@ def f: Unit =
66
42
77
)
88

9-
def g: Unit =
10-
identity(
11-
x =
12-
class X extends AnyRef, Serializable
13-
27
14-
)
15-
169
def test: Unit =
1710
assert(
1811
identity:
@@ -26,6 +19,11 @@ def toss: Unit =
2619
null,
2720
"ok"
2821
)
22+
def raise: Unit =
23+
assert(
24+
throw
25+
null, "ok" // ok now
26+
)
2927

3028
def callme[A](x: => A, msg: String) = try x.toString catch case t: RuntimeException => msg
3129

@@ -63,3 +61,12 @@ def k(xs: List[Int], y: Int, z: Int) =
6361
z,
6462
)
6563
)
64+
65+
object `arrow eol`:
66+
def f(g: Int => Int, i: Int): Int = g(i)
67+
def g(map: Int => Int): Int => Int = map
68+
def test =
69+
f(
70+
g: x =>
71+
x + 1, 42
72+
)

0 commit comments

Comments
 (0)