Skip to content

Commit 59aa201

Browse files
KacperFKorbantgodzik
authored andcommitted
Do not crash when typing a closure with unknown type, since it can occur for erroneous input
1 parent 3d92f14 commit 59aa201

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,8 +1722,6 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
17221722
EmptyTree
17231723
}
17241724
case tp =>
1725-
if !tp.isErroneous then
1726-
throw new java.lang.Error(i"internal error: closing over non-method $tp, pos = ${tree.span}")
17271725
TypeTree(defn.AnyType)
17281726
}
17291727
else typed(tree.tpt)

tests/neg/i20511-1.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package pakiet
2+
3+
def toppingPrice(size: Int): Double = ???
4+
5+
def crustPrice(crustType: Double): Double = ???
6+
7+
export toppingPrice.apply, crustPrice.unlift // error // error // error

tests/neg/i20511.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package pakiet
2+
3+
def toppingPrice(size: Int): Double = ???
4+
5+
def crustPrice(crustType: Double): Double = ???
6+
7+
export toppingPrice, crustPrice // error // error
8+
val i = 1 // error

0 commit comments

Comments
 (0)