Skip to content

Commit 8274988

Browse files
committed
Simplify erased parameter syntax
erased is not always a modifier on the parameter name. The syntax `erased Type` is dropped. There's not really a need for this syntactic inconsistency. [Cherry-picked 6159045][modified]
1 parent c123c20 commit 8274988

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1619,7 +1619,7 @@ object Parsers {
16191619
() => funParam(in.offset, imods))
16201620
case t =>
16211621
def funArg() =
1622-
addErased()
1622+
erasedArgs.addOne(false)
16231623
funArgType()
16241624
commaSeparatedRest(t, funArg)
16251625
accept(RPAREN)

tests/neg/lambda-infer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//> using options -language:experimental.erasedDefinitions
22

3-
type F = (Int, erased Int) => Int
3+
type F = (x: Int, erased y: Int) => Int
44

55
erased class A
66

@@ -14,7 +14,7 @@ erased class A
1414

1515
use { (x, y) => x } // error: Expected F got (Int, Int) => Int
1616

17-
def singleParam(f: (erased Int) => Int) = f(5)
17+
def singleParam(f: (erased x: Int) => Int) = f(5)
1818

1919
singleParam(x => 5) // error: Expected (erased Int) => Int got Int => Int
2020
singleParam((erased x) => 5) // ok

tests/run/erased-lambdas.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
// lambdas should parse and work
55

6-
type F = (erased Int, String) => String
7-
type S = (Int, erased String) => Int
6+
type F = (erased x: Int, y: String) => String
7+
type S = (x: Int, erased y: String) => Int
88

99
def useF(f: F) = f(5, "a")
1010
def useS(f: S) = f(5, "a")
@@ -16,7 +16,7 @@ val fsExpl = (x: Int, erased y: String) => x
1616

1717
// contextual lambdas should work
1818

19-
type FC = (Int, erased String) ?=> Int
19+
type FC = (x: Int, erased y: String) ?=> Int
2020

2121
def useCtx(f: FC) = f(using 5, "a")
2222

@@ -25,7 +25,7 @@ val fCvExpl = (x: Int, erased y: String) ?=> x
2525

2626
// nested lambdas should work
2727

28-
val nested: Int => (String, erased Int) => FC = a => (_, erased _) => (c, erased d) ?=> a + c
28+
val nested: Int => (x: String, erased y: Int) => FC = a => (_, erased _) => (c, erased d) ?=> a + c
2929

3030
@main def Test() =
3131
assert("a" == useF(ff))

0 commit comments

Comments
 (0)