Skip to content

Commit 094dc75

Browse files
committed
Keep inherited names through erasure
If the original name in a selection is a inherited name, the erased name should also be one.
1 parent 52db988 commit 094dc75

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/dotty/tools/dotc/transform/Erasure.scala

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,14 @@ object Erasure {
267267
val sym = tree.symbol
268268
assert(sym.exists, tree.show)
269269

270-
def select(qual: Tree, sym: Symbol): Tree =
271-
untpd.cpy.Select(tree)(qual, sym.name) withType qual.tpe.select(sym)
270+
def select(qual: Tree, sym: Symbol): Tree = {
271+
val name = tree.typeOpt match {
272+
case tp: NamedType if tp.name.isInheritedName => sym.name.inheritedName
273+
case _ => sym.name
274+
}
275+
untpd.cpy.Select(tree)(qual, sym.name)
276+
.withType(NamedType.withSymAndName(qual.tpe, sym, name))
277+
}
272278

273279
def selectArrayMember(qual: Tree, erasedPre: Type): Tree =
274280
if (erasedPre isRef defn.ObjectClass)
@@ -307,7 +313,10 @@ object Erasure {
307313

308314
override def typedThis(tree: untpd.This)(implicit ctx: Context): Tree =
309315
if (tree.symbol == ctx.owner.enclosingClass || tree.symbol.isStaticOwner) promote(tree)
310-
else outer.path(tree.symbol)
316+
else {
317+
ctx.log(i"computing outer path from ${ctx.owner.ownersIterator.toList}%, % to ${tree.symbol}")
318+
outer.path(tree.symbol)
319+
}
311320

312321
private def runtimeCallWithProtoArgs(name: Name, pt: Type, args: Tree*)(implicit ctx: Context): Tree = {
313322
val meth = defn.runtimeMethod(name)

0 commit comments

Comments
 (0)