Skip to content

Commit 2f94c3d

Browse files
committed
Refine validity checking
When defining a class in the interpreter we had a case where the class was accessed at phase 46 in the backend, yet the denotation was the initial denotation in a previous run. In that case we have to check again at the phase where the denotation is valid. This was not done before, and hence the owner of the denbotation did not contain the symbol because the backend phase is after flatten.
1 parent 6324a75 commit 2f94c3d

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,22 @@ trait SymDenotations { this: Context =>
4545
if (denot.is(ValidForever) || denot.isRefinementClass) true
4646
else {
4747
val initial = denot.initial
48-
if (initial ne denot)
49-
ctx.withPhase(initial.validFor.firstPhaseId).stillValid(initial.asSymDenotation)
50-
else try {
51-
val owner = denot.owner.denot
52-
stillValid(owner) && (
53-
!owner.isClass
54-
|| owner.isRefinementClass
55-
|| (owner.unforcedDecls.lookupAll(denot.name) contains denot.symbol)
56-
|| denot.isSelfSym)
57-
} catch {
58-
case ex: StaleSymbol => false
59-
}
48+
if ((initial ne denot) || ctx.phaseId != initial.validFor.firstPhaseId)
49+
ctx.withPhase(initial.validFor.firstPhaseId).stillValidInOwner(initial.asSymDenotation)
50+
else
51+
stillValidInOwner(denot)
52+
}
53+
54+
private[SymDenotations] def stillValidInOwner(denot: SymDenotation): Boolean = try {
55+
val owner = denot.owner.denot
56+
stillValid(owner) && (
57+
!owner.isClass
58+
|| owner.isRefinementClass
59+
|| (owner.unforcedDecls.lookupAll(denot.name) contains denot.symbol)
60+
|| denot.isSelfSym)
61+
} catch {
62+
case ex: StaleSymbol => false
63+
}
6064

6165
/** Explain why symbol is invalid; used for debugging only */
6266
def traceInvalid(denot: Denotation): Boolean = {

0 commit comments

Comments
 (0)