Skip to content

Commit ccc69d9

Browse files
committed
Fix #10253: Fix result type of outer accessors
Use the actual prefix of the base type rather than an applied ThisType
1 parent 6b9796c commit ccc69d9

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,14 @@ object ExplicitOuter {
169169
private def newOuterSym(owner: ClassSymbol, cls: ClassSymbol, name: TermName, flags: FlagSet)(using Context) = {
170170
val outerThis = owner.owner.enclosingClass.thisType
171171
val outerCls = outerClass(cls)
172+
val prefix = owner.thisType.baseType(cls).normalizedPrefix
172173
val target =
173174
if (owner == cls)
174175
outerCls.appliedRef
175176
else
176-
outerThis.baseType(outerCls).orElse(
177-
outerCls.typeRef.appliedTo(outerCls.typeParams.map(_ => TypeBounds.empty)))
177+
outerThis.baseType(outerCls)
178+
.orElse(prefix.widen)
179+
.orElse(outerCls.typeRef.appliedTo(outerCls.typeParams.map(_ => TypeBounds.empty)))
178180
val info = if (flags.is(Method)) ExprType(target) else target
179181
atPhaseNoEarlier(explicitOuterPhase.next) { // outer accessors are entered at explicitOuter + 1, should not be defined before.
180182
newSymbol(owner, name, Synthetic | flags, info, coord = cls.coord)

tests/pos/i10253.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
object test:
2+
def foo(qc: QC): Unit =
3+
object treeMap extends qc.reflect.TreeMap
4+
5+
trait QC:
6+
val reflect: Reflection
7+
trait Reflection:
8+
trait TreeMap:
9+
def transformTree: Unit = ???

0 commit comments

Comments
 (0)