diff options
author | Martin Odersky <odersky@gmail.com> | 2014-10-22 11:47:43 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-10-26 16:24:01 +0100 |
commit | 651ff01e07b90c481e30afdd1500f617d74aeeb4 (patch) | |
tree | 82a54d6938093a5f8002eca3128e6c17ac913ec4 | |
parent | 854373753526248737ee554290b73fa583f0c264 (diff) | |
download | dotty-651ff01e07b90c481e30afdd1500f617d74aeeb4.tar.gz dotty-651ff01e07b90c481e30afdd1500f617d74aeeb4.tar.bz2 dotty-651ff01e07b90c481e30afdd1500f617d74aeeb4.zip |
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.
-rw-r--r-- | src/dotty/tools/dotc/transform/LambdaLift.scala | 10 | ||||
-rw-r--r-- | tests/pending/pos/tailcall/t1672.scala (renamed from tests/pos/tailcall/t1672.scala) | 0 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/transform/LambdaLift.scala b/src/dotty/tools/dotc/transform/LambdaLift.scala index cd74da603..f34b5479a 100644 --- a/src/dotty/tools/dotc/transform/LambdaLift.scala +++ b/src/dotty/tools/dotc/transform/LambdaLift.scala @@ -31,7 +31,7 @@ class LambdaLift extends MiniPhaseTransform with IdentityDenotTransformer { this import ast.tpd._ /** the following two members override abstract members in Transform */ - val phaseName: String = "lambdalift" + val phaseName: String = "lambdaLift" override def runsAfter: Set[Class[_ <: Phase]] = Set(classOf[Constructors]) // Constructors has to happen before LambdaLift because the lambda lift logic @@ -164,9 +164,13 @@ class LambdaLift extends MiniPhaseTransform with IdentityDenotTransformer { this val sym = tree.symbol tree match { case tree: Ident => - if (sym.maybeOwner.isTerm) - if (sym is (Method, butNot = Label)) markCalled(sym, enclosure) + if (sym.maybeOwner.isTerm) { + if (sym is Label) + assert(enclosure == sym.enclosure, + i"attempt to refer to label $sym from nested $enclosure") + else if (sym is Method) markCalled(sym, enclosure) else if (sym.isTerm) markFree(sym, enclosure) + } case tree: Select => if (sym.isConstructor && sym.owner.owner.isTerm) markCalled(sym, enclosure) diff --git a/tests/pos/tailcall/t1672.scala b/tests/pending/pos/tailcall/t1672.scala index 9be5c6066..9be5c6066 100644 --- a/tests/pos/tailcall/t1672.scala +++ b/tests/pending/pos/tailcall/t1672.scala |