aboutsummaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-04-11 09:22:56 +0200
committerMartin Odersky <odersky@gmail.com>2017-04-11 14:11:58 +0200
commit0eb06db64b66a63d722ba580d5e94506febd9dc8 (patch)
treec8f39d564cdfd67c75eb508e93a54c99676084b1 /compiler
parente4a6d72a52b4b9c3ce5530197352ca11e11fc9aa (diff)
downloaddotty-0eb06db64b66a63d722ba580d5e94506febd9dc8.tar.gz
dotty-0eb06db64b66a63d722ba580d5e94506febd9dc8.tar.bz2
dotty-0eb06db64b66a63d722ba580d5e94506febd9dc8.zip
Handle supercalls in inner classes correctly
The previous fix was too coarse. We need to move an anonymous function in a supercall towards the call, we just have to make sure it's not in the directly enclosing class.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/src/dotty/tools/dotc/transform/LambdaLift.scala13
1 files changed, 8 insertions, 5 deletions
diff --git a/compiler/src/dotty/tools/dotc/transform/LambdaLift.scala b/compiler/src/dotty/tools/dotc/transform/LambdaLift.scala
index 3880b6efb..a729368d4 100644
--- a/compiler/src/dotty/tools/dotc/transform/LambdaLift.scala
+++ b/compiler/src/dotty/tools/dotc/transform/LambdaLift.scala
@@ -143,14 +143,17 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform
/** Set `liftedOwner(sym)` to `owner` if `owner` is more deeply nested
* than the previous value of `liftedowner(sym)`.
*/
- def narrowLiftedOwner(sym: Symbol, owner: Symbol)(implicit ctx: Context) =
+ def narrowLiftedOwner(sym: Symbol, owner: Symbol)(implicit ctx: Context): Unit =
if (sym.maybeOwner.isTerm &&
owner.isProperlyContainedIn(liftedOwner(sym)) &&
- !sym.is(InSuperCall) &&
owner != sym) {
- ctx.log(i"narrow lifted $sym to $owner")
- changedLiftedOwner = true
- liftedOwner(sym) = owner
+ if (sym.is(InSuperCall) && owner.isProperlyContainedIn(sym.enclosingClass))
+ narrowLiftedOwner(sym, sym.enclosingClass)
+ else {
+ ctx.log(i"narrow lifted $sym to $owner")
+ changedLiftedOwner = true
+ liftedOwner(sym) = owner
+ }
}
/** Mark symbol `sym` as being free in `enclosure`, unless `sym` is defined