From ff782651ee5e5a3aa9a3d1b72b2b1fdaa26eafca Mon Sep 17 00:00:00 2001 From: liu fengyun Date: Mon, 10 Apr 2017 17:28:57 +0200 Subject: fix #2163: don't narrow liftedOwner if symbol is InSuperCall --- compiler/src/dotty/tools/dotc/transform/LambdaLift.scala | 1 + tests/run/i2163.check | 1 + tests/run/i2163.scala | 9 +++++++++ 3 files changed, 11 insertions(+) create mode 100644 tests/run/i2163.check create mode 100644 tests/run/i2163.scala diff --git a/compiler/src/dotty/tools/dotc/transform/LambdaLift.scala b/compiler/src/dotty/tools/dotc/transform/LambdaLift.scala index 7578b57f1..3880b6efb 100644 --- a/compiler/src/dotty/tools/dotc/transform/LambdaLift.scala +++ b/compiler/src/dotty/tools/dotc/transform/LambdaLift.scala @@ -146,6 +146,7 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform def narrowLiftedOwner(sym: Symbol, owner: Symbol)(implicit ctx: Context) = if (sym.maybeOwner.isTerm && owner.isProperlyContainedIn(liftedOwner(sym)) && + !sym.is(InSuperCall) && owner != sym) { ctx.log(i"narrow lifted $sym to $owner") changedLiftedOwner = true diff --git a/tests/run/i2163.check b/tests/run/i2163.check new file mode 100644 index 000000000..7f8f011eb --- /dev/null +++ b/tests/run/i2163.check @@ -0,0 +1 @@ +7 diff --git a/tests/run/i2163.scala b/tests/run/i2163.scala new file mode 100644 index 000000000..67c4adb31 --- /dev/null +++ b/tests/run/i2163.scala @@ -0,0 +1,9 @@ +class Base(f: Int => Int) { + f(3) +} + +class Child(x: Int) extends Base(y => x + y) + +object Test { + def main(args: Array[String]): Unit = new Child(4) +} -- cgit v1.2.3