diff options
-rw-r--r-- | compiler/src/dotty/tools/dotc/core/TypeApplications.scala | 2 | ||||
-rw-r--r-- | compiler/src/dotty/tools/dotc/transform/LambdaLift.scala | 12 | ||||
-rw-r--r-- | tests/pos/i2219.scala | 7 | ||||
-rw-r--r-- | tests/run/i2163.scala | 21 |
4 files changed, 37 insertions, 5 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/TypeApplications.scala b/compiler/src/dotty/tools/dotc/core/TypeApplications.scala index 82051b66c..b37ed2b0a 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeApplications.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeApplications.scala @@ -429,7 +429,7 @@ class TypeApplications(val self: Type) extends AnyVal { case dealiased: LazyRef => LazyRef(() => dealiased.ref.appliedTo(args)) case dealiased: WildcardType => - dealiased + WildcardType(dealiased.optBounds.appliedTo(args).bounds) case dealiased: TypeRef if dealiased.symbol == defn.NothingClass => dealiased case _ if typParams.isEmpty || typParams.head.isInstanceOf[LambdaParam] => diff --git a/compiler/src/dotty/tools/dotc/transform/LambdaLift.scala b/compiler/src/dotty/tools/dotc/transform/LambdaLift.scala index 7578b57f1..a729368d4 100644 --- a/compiler/src/dotty/tools/dotc/transform/LambdaLift.scala +++ b/compiler/src/dotty/tools/dotc/transform/LambdaLift.scala @@ -143,13 +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)) && 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 diff --git a/tests/pos/i2219.scala b/tests/pos/i2219.scala new file mode 100644 index 000000000..7f786eb3e --- /dev/null +++ b/tests/pos/i2219.scala @@ -0,0 +1,7 @@ +object Test { + type Inv[T[_]] = T[_] + + class Hi[T[_]](x: Inv[T]) { + def foo[T[_]](value: Inv[T] = x) = {} + } +} diff --git a/tests/run/i2163.scala b/tests/run/i2163.scala new file mode 100644 index 000000000..952f651e3 --- /dev/null +++ b/tests/run/i2163.scala @@ -0,0 +1,21 @@ +class Base(f: Int => Int) { + def result = f(3) +} + +class Child(x: Int) extends Base(y => x + y) + +class Outer(z: Int) { + class Base(f: Int => Int) { + def result = f(3) + } + + class Child(x: Int) extends Base(y => x + y + z) +} + +object Test { + def main(args: Array[String]): Unit = { + assert(new Child(4).result == 7) + val o = new Outer(2) + assert(new o.Child(2).result == 7) + } +} |