diff options
-rw-r--r-- | src/dotty/tools/dotc/Compiler.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/transform/LambdaLift.scala | 6 | ||||
-rw-r--r-- | tests/pending/pos/llift.scala | 16 | ||||
-rw-r--r-- | tests/run/llift.scala | 16 |
4 files changed, 20 insertions, 20 deletions
diff --git a/src/dotty/tools/dotc/Compiler.scala b/src/dotty/tools/dotc/Compiler.scala index d526903b8..967fb395a 100644 --- a/src/dotty/tools/dotc/Compiler.scala +++ b/src/dotty/tools/dotc/Compiler.scala @@ -75,7 +75,7 @@ class Compiler { new Constructors, // constructors changes decls in transformTemplate, no InfoTransformers should be added after it new FunctionalInterfaces, new GetClass), // getClass transformation should be applied to specialized methods - List(new LambdaLift, // in this mini-phase block scopes are incorrect. No phases that rely on scopes should be here + List(new LambdaLift, // in this mini-phase block scopes are incorrect. No phases that rely on scopes should be here new ElimStaticThis, new Flatten, // new DropEmptyCompanions, diff --git a/src/dotty/tools/dotc/transform/LambdaLift.scala b/src/dotty/tools/dotc/transform/LambdaLift.scala index dfc8c77dc..8b79bec58 100644 --- a/src/dotty/tools/dotc/transform/LambdaLift.scala +++ b/src/dotty/tools/dotc/transform/LambdaLift.scala @@ -133,7 +133,7 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform val owner = sym.maybeOwner owner.isTerm || owner.is(Trait) && isLocal(owner) || - sym.isConstructor && isLocal(sym.owner) + sym.isConstructor && isLocal(owner) } /** Set `liftedOwner(sym)` to `owner` if `owner` is more deeply nested @@ -223,7 +223,7 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform } private def markCalled(callee: Symbol, caller: Symbol)(implicit ctx: Context): Unit = { - ctx.debuglog(i"mark called: $callee of ${callee.owner} is called by $caller") + ctx.debuglog(i"mark called: $callee of ${callee.owner} is called by $caller in ${caller.owner}") assert(isLocal(callee)) symSet(called, caller) += callee if (callee.enclosingClass != caller.enclosingClass) calledFromInner += callee @@ -261,7 +261,7 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform // top-level class. This avoids possible deadlocks when a static method // has to access its enclosing object from the outside. else if (sym.isConstructor) { - if (sym.isPrimaryConstructor && sym.owner.owner.isTerm && !sym.owner.is(Trait)) + if (sym.isPrimaryConstructor && isLocal(sym.owner) && !sym.owner.is(Trait)) // add a call edge from the constructor of a local non-trait class to // the class itself. This is done so that the constructor inherits // the free variables of the class. diff --git a/tests/pending/pos/llift.scala b/tests/pending/pos/llift.scala deleted file mode 100644 index b2a1e163b..000000000 --- a/tests/pending/pos/llift.scala +++ /dev/null @@ -1,16 +0,0 @@ -object Test { - def f1d(x: Int) = { - trait T1 { -// def f2 = { - trait T2 { - def f3: Int = x - } - class C2 extends T2 - new C2().f3 -// } - def f6 = x - } - class C1 extends T1 - new C1().f6 - } -} diff --git a/tests/run/llift.scala b/tests/run/llift.scala index 28456b8cc..60a1f4dce 100644 --- a/tests/run/llift.scala +++ b/tests/run/llift.scala @@ -128,6 +128,21 @@ object Test { new C1().f6 } + def f1f(x: Int) = { + trait T1 { + trait T2 { + def f3: Int = x + } + class C2 extends T2 { + override def f3 = super.f3 + } + new C2().f3 + def f6 = x + } + class C1 extends T1 + new C1().f6 + } + def main(args: Array[String]) = { assert(foo(3) == 3) assert(f1(4) == 4) @@ -136,5 +151,6 @@ object Test { assert(f1c(7) == 14) assert(f1d(8) == 16) assert(f1e(9) == 9) + assert(f1f(10) == 10) } } |