Skip to content

Commit b2e0e7b

Browse files
committed
tpd.TreeOps#select creates non member syms after erasure.
Without this patch, ast.TreeInfo does not compile wfter next commit "Erasure should keep prefixes in TermRefs". The reason is that outer path genertion generates a data race between - an outer accessor created in ExplicitOuter - a copy of the accessor created in ElimByName in a TreeTypeMap copy. The patch avoids the data race by using a fixed symbol for the new TermRef generated in outer.path during erasure. But the fix seems ad-hoc. We should try to attack the problem at the root in TypeTreeMap. The root problem seems to be that TypeTreeMap generates a copy of symbols whnMemere the copies of the symbols give the same named type as the originals. We can either label the copied symbols so that any types created from them become instances of WithNonMemberSym (which probably should be renamed then). Or else we have a "linear" version of TreeMap that overrides sym denotations instead of creating new symbols.
1 parent 094dc75 commit b2e0e7b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,8 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
522522

523523
def select(sym: Symbol)(implicit ctx: Context): Select =
524524
untpd.Select(tree, sym.name).withType(
525-
TermRef.withSigAndDenot(tree.tpe, sym.name.asTermName, sym.signature, sym.denot.asSeenFrom(tree.tpe)))
525+
if (ctx.erasedTypes) TermRef.withNonMemberSym(tree.tpe, sym.name.asTermName, sym.asTerm)
526+
else TermRef.withSigAndDenot(tree.tpe, sym.name.asTermName, sym.signature, sym.denot.asSeenFrom(tree.tpe)))
526527

527528
def selectWithSig(name: Name, sig: Signature)(implicit ctx: Context) =
528529
untpd.SelectWithSig(tree, name, sig)

0 commit comments

Comments
 (0)