File tree 2 files changed +29
-4
lines changed
compiler/src/dotty/tools/dotc/transform
2 files changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -143,13 +143,17 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform
143
143
/** Set `liftedOwner(sym)` to `owner` if `owner` is more deeply nested
144
144
* than the previous value of `liftedowner(sym)`.
145
145
*/
146
- def narrowLiftedOwner (sym : Symbol , owner : Symbol )(implicit ctx : Context ) =
146
+ def narrowLiftedOwner (sym : Symbol , owner : Symbol )(implicit ctx : Context ): Unit =
147
147
if (sym.maybeOwner.isTerm &&
148
148
owner.isProperlyContainedIn(liftedOwner(sym)) &&
149
149
owner != sym) {
150
- ctx.log(i " narrow lifted $sym to $owner" )
151
- changedLiftedOwner = true
152
- liftedOwner(sym) = owner
150
+ if (sym.is(InSuperCall ) && owner.isProperlyContainedIn(sym.enclosingClass))
151
+ narrowLiftedOwner(sym, sym.enclosingClass)
152
+ else {
153
+ ctx.log(i " narrow lifted $sym to $owner" )
154
+ changedLiftedOwner = true
155
+ liftedOwner(sym) = owner
156
+ }
153
157
}
154
158
155
159
/** Mark symbol `sym` as being free in `enclosure`, unless `sym` is defined
Original file line number Diff line number Diff line change
1
+ class Base (f : Int => Int ) {
2
+ def result = f(3 )
3
+ }
4
+
5
+ class Child (x : Int ) extends Base (y => x + y)
6
+
7
+ class Outer (z : Int ) {
8
+ class Base (f : Int => Int ) {
9
+ def result = f(3 )
10
+ }
11
+
12
+ class Child (x : Int ) extends Base (y => x + y + z)
13
+ }
14
+
15
+ object Test {
16
+ def main (args : Array [String ]): Unit = {
17
+ assert(new Child (4 ).result == 7 )
18
+ val o = new Outer (2 )
19
+ assert(new o.Child (2 ).result == 7 )
20
+ }
21
+ }
You can’t perform that action at this time.
0 commit comments