diff options
-rw-r--r-- | compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala | 3 | ||||
-rw-r--r-- | tests/pos/i1865.scala | 24 |
2 files changed, 26 insertions, 1 deletions
diff --git a/compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala b/compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala index 1eb12e9de..c2aacf826 100644 --- a/compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala +++ b/compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala @@ -276,7 +276,8 @@ object ExplicitOuter { if (tpe.prefix eq NoPrefix) cls.owner.enclosingClass.thisType else tpe.prefix case _ => - outerPrefix(tpe.underlying) + // Need to be careful to dealias before erasure, otherwise we lose prefixes. + outerPrefix(tpe.underlying(ctx.withPhaseNoLater(ctx.erasurePhase))) } case tpe: TypeProxy => outerPrefix(tpe.underlying) diff --git a/tests/pos/i1865.scala b/tests/pos/i1865.scala new file mode 100644 index 000000000..1b77558ff --- /dev/null +++ b/tests/pos/i1865.scala @@ -0,0 +1,24 @@ +class AbsCell { + type T = Node + class Node +} + +object Test { + def test: Unit = { + val cell = new AbsCell + new cell.T + } +} + +class AbsCell2 { + type T = Node + val value: T = value + def set(x: T): Unit = {} + class Node +} +object init { + def main = { + val cell = new AbsCell2 { val init = new Node } + cell set (new cell.T) + } +} |