Skip to content

Commit d2b7080

Browse files
committed
Avoid returning stale symbols from NamedType#symbol
There's a scenario where a NamedType is created with an initial symbol but no denotation yet. If the denotation of that NamedType is first computed in a subsequent run, the initially given symbol might be stale, so the symbol should be recomputed from the denotation.
1 parent 22440f3 commit d2b7080

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1737,7 +1737,9 @@ object Types {
17371737
def symbol(implicit ctx: Context): Symbol = {
17381738
val now = ctx.period
17391739
if (checkedPeriod == now ||
1740-
lastDenotation == null && lastSymbol != null) lastSymbol
1740+
lastDenotation == null && lastSymbol != null &&
1741+
(checkedPeriod.runId == now.runId || ctx.stillValid(lastSymbol)))
1742+
lastSymbol
17411743
else denot.symbol
17421744
}
17431745

0 commit comments

Comments
 (0)