Skip to content

Commit 74920d3

Browse files
committed
Don't typeAhead erroneous parsing trees related to export statements
1 parent ec5cbcc commit 74920d3

File tree

4 files changed

+46
-2
lines changed

4 files changed

+46
-2
lines changed

Diff for: compiler/src/dotty/tools/dotc/typer/Namer.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,7 @@ class Namer { typer: Typer =>
11311131
private def exportForwarders(exp: Export, pathMethod: Symbol)(using Context): List[tpd.MemberDef] =
11321132
val buf = new mutable.ListBuffer[tpd.MemberDef]
11331133
val Export(expr, selectors) = exp
1134-
if expr.isEmpty then
1134+
if expr.isEmpty || selectors.exists(_.imported.name == nme.ERROR) then
11351135
report.error(em"Export selector must have prefix and `.`", exp.srcPos)
11361136
return Nil
11371137

Diff for: tests/neg/i20511-1.check

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
-- [E083] Type Error: tests/neg/i20511-1.scala:7:7 ---------------------------------------------------------------------
2+
7 |export toppingPrice.apply, crustPrice.apply, crustPrice.unlift // error // error // error // error // error
3+
| ^^^^^^^^^^^^
4+
| Int => Double is not a valid export prefix, since it is not an immutable path
5+
|
6+
| longer explanation available when compiling with `-explain`
7+
-- [E083] Type Error: tests/neg/i20511-1.scala:7:27 --------------------------------------------------------------------
8+
7 |export toppingPrice.apply, crustPrice.apply, crustPrice.unlift // error // error // error // error // error
9+
| ^^^^^^^^^^
10+
| Any is not a valid export prefix, since it is not an immutable path
11+
|
12+
| longer explanation available when compiling with `-explain`
13+
-- Error: tests/neg/i20511-1.scala:7:38 --------------------------------------------------------------------------------
14+
7 |export toppingPrice.apply, crustPrice.apply, crustPrice.unlift // error // error // error // error // error
15+
| ^^^^^
16+
| no eligible member apply at {
17+
| def $anonfun(crustType: Double): Double = pakiet.crustPrice(crustType)
18+
| closure(pakiet.$anonfun:Any)
19+
| }
20+
-- [E083] Type Error: tests/neg/i20511-1.scala:7:45 --------------------------------------------------------------------
21+
7 |export toppingPrice.apply, crustPrice.apply, crustPrice.unlift // error // error // error // error // error
22+
| ^^^^^^^^^^
23+
| Any is not a valid export prefix, since it is not an immutable path
24+
|
25+
| longer explanation available when compiling with `-explain`
26+
-- Error: tests/neg/i20511-1.scala:7:56 --------------------------------------------------------------------------------
27+
7 |export toppingPrice.apply, crustPrice.apply, crustPrice.unlift // error // error // error // error // error
28+
| ^^^^^^
29+
| no eligible member unlift at {
30+
| def $anonfun(crustType: Double): Double = pakiet.crustPrice(crustType)
31+
| closure(pakiet.$anonfun:Any)
32+
| }

Diff for: tests/neg/i20511-1.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ def toppingPrice(size: Int): Double = ???
44

55
def crustPrice(crustType: Double): Double = ???
66

7-
export toppingPrice.apply, crustPrice.unlift // error // error // error
7+
export toppingPrice.apply, crustPrice.apply, crustPrice.unlift // error // error // error // error // error

Diff for: tests/neg/i20511.check

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- [E040] Syntax Error: tests/neg/i20511.scala:7:19 --------------------------------------------------------------------
2+
7 |export toppingPrice, crustPrice // error // error
3+
| ^
4+
| '.' expected, but ',' found
5+
-- [E040] Syntax Error: tests/neg/i20511.scala:8:0 ---------------------------------------------------------------------
6+
8 |val i = 1 // error
7+
|^^^
8+
|'.' expected, but 'end of statement' found
9+
-- Error: tests/neg/i20511.scala:7:21 ----------------------------------------------------------------------------------
10+
7 |export toppingPrice, crustPrice // error // error
11+
| ^^^^^^^^^^
12+
| Export selector must have prefix and `.`

0 commit comments

Comments
 (0)