Skip to content

Commit ac583c5

Browse files
committed
Better diagnostic from LambdaLift
1 parent 8ae2853 commit ac583c5

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/dotty/tools/dotc/transform/LambdaLift.scala

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import collection.{ mutable, immutable }
2222
import collection.mutable.{ HashMap, HashSet, LinkedHashMap, LinkedHashSet, TreeSet }
2323

2424
object LambdaLift {
25-
val NJ = NameTransformer.NAME_JOIN_STRING
25+
private val NJ = NameTransformer.NAME_JOIN_STRING
26+
private class NoPath extends Exception
2627
}
2728

2829
class LambdaLift extends MiniPhaseTransform with IdentityDenotTransformer { thisTransform =>
@@ -125,7 +126,8 @@ class LambdaLift extends MiniPhaseTransform with IdentityDenotTransformer { this
125126
* }
126127
* }
127128
*/
128-
private def markFree(sym: Symbol, enclosure: Symbol)(implicit ctx: Context): Boolean = {
129+
private def markFree(sym: Symbol, enclosure: Symbol)(implicit ctx: Context): Boolean = try {
130+
if (!enclosure.exists) throw new NoPath
129131
println(i"mark free: ${sym.showLocated} with owner ${sym.maybeOwner} marked free in $enclosure")
130132
(enclosure == sym.enclosure) || {
131133
ctx.debuglog(i"$enclosure != ${sym.enclosure}")
@@ -143,6 +145,11 @@ class LambdaLift extends MiniPhaseTransform with IdentityDenotTransformer { this
143145
}
144146
}
145147
}
148+
catch {
149+
case ex: NoPath =>
150+
println(i"error lambda lifting ${ctx.compilationUnit}: $sym is not visible from $enclosure")
151+
throw ex
152+
}
146153

147154
private def markCalled(callee: Symbol, caller: Symbol)(implicit ctx: Context): Unit = {
148155
ctx.debuglog(i"mark called: $callee of ${callee.owner} is called by $caller")

0 commit comments

Comments
 (0)