diff options
author | liu fengyun <liu@fengy.me> | 2017-04-10 17:28:57 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2017-04-11 14:11:57 +0200 |
commit | ff782651ee5e5a3aa9a3d1b72b2b1fdaa26eafca (patch) | |
tree | f37892c4f4c2373e60da455be37be6f8152c1bac | |
parent | 92a9d05fd64ac97140aa0f01214c4738526383c3 (diff) | |
download | dotty-ff782651ee5e5a3aa9a3d1b72b2b1fdaa26eafca.tar.gz dotty-ff782651ee5e5a3aa9a3d1b72b2b1fdaa26eafca.tar.bz2 dotty-ff782651ee5e5a3aa9a3d1b72b2b1fdaa26eafca.zip |
fix #2163: don't narrow liftedOwner if symbol is InSuperCall
-rw-r--r-- | compiler/src/dotty/tools/dotc/transform/LambdaLift.scala | 1 | ||||
-rw-r--r-- | tests/run/i2163.check | 1 | ||||
-rw-r--r-- | tests/run/i2163.scala | 9 |
3 files changed, 11 insertions, 0 deletions
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) +} |