Skip to content

Commit 651ff01

Browse files
committed
LambdaLift checks now explicitly for references to labels outside scope.
Nested methods cannot refer to labels in theior environment. Needs a fix in TailCalls. Moved failing test to pending.
1 parent 8543737 commit 651ff01

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class LambdaLift extends MiniPhaseTransform with IdentityDenotTransformer { this
3131
import ast.tpd._
3232

3333
/** the following two members override abstract members in Transform */
34-
val phaseName: String = "lambdalift"
34+
val phaseName: String = "lambdaLift"
3535

3636
override def runsAfter: Set[Class[_ <: Phase]] = Set(classOf[Constructors])
3737
// Constructors has to happen before LambdaLift because the lambda lift logic
@@ -164,9 +164,13 @@ class LambdaLift extends MiniPhaseTransform with IdentityDenotTransformer { this
164164
val sym = tree.symbol
165165
tree match {
166166
case tree: Ident =>
167-
if (sym.maybeOwner.isTerm)
168-
if (sym is (Method, butNot = Label)) markCalled(sym, enclosure)
167+
if (sym.maybeOwner.isTerm) {
168+
if (sym is Label)
169+
assert(enclosure == sym.enclosure,
170+
i"attempt to refer to label $sym from nested $enclosure")
171+
else if (sym is Method) markCalled(sym, enclosure)
169172
else if (sym.isTerm) markFree(sym, enclosure)
173+
}
170174
case tree: Select =>
171175
if (sym.isConstructor && sym.owner.owner.isTerm)
172176
markCalled(sym, enclosure)

0 commit comments

Comments
 (0)