Skip to content

Commit fdd20f4

Browse files
committed
Make changeOwnerAfter more robust wrt NotDefinedHere errors
It can happen that changeOwner sees symbols that are not defined yet at the phase where the method is run. Such symbols should be ignored.
1 parent f5a94f7 commit fdd20f4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,8 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
641641
def traverse(tree: Tree)(implicit ctx: Context) = tree match {
642642
case tree: DefTree =>
643643
val sym = tree.symbol
644-
if (sym.denot(ctx.withPhase(trans)).owner == from) {
644+
val prevDenot = sym.denot(ctx.withPhase(trans))
645+
if (prevDenot.validFor.containsPhaseId(trans.id) && prevDenot.owner == from) {
645646
val d = sym.copySymDenotation(owner = to)
646647
d.installAfter(trans)
647648
d.transformAfter(trans, d => if (d.owner eq from) d.copySymDenotation(owner = to) else d)
@@ -651,7 +652,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
651652
traverseChildren(tree)
652653
}
653654
}
654-
traverser.traverse(tree)
655+
traverser.traverse(tree)(ctx.withMode(Mode.FutureDefsOK))
655656
tree
656657
}
657658

0 commit comments

Comments
 (0)