Skip to content

Commit 9ab7adf

Browse files
oderskyWojciechMazur
authored andcommitted
Avoid setting lastDenot to NoDenotation in the forward reference scenario
This brings back an element of the original solution. [Cherry-picked 5631d76]
1 parent c232ff5 commit 9ab7adf

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

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

+7-6
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,16 @@ object Symbols extends SymUtils {
117117
protected def recomputeDenot(lastd: SymDenotation)(using Context): SymDenotation = {
118118
util.Stats.record("Symbol.recomputeDenot")
119119
val newd = lastd.current.asInstanceOf[SymDenotation]
120-
lastDenot = newd
121-
if !newd.exists && lastd.initial.validFor.firstPhaseId > ctx.phaseId then
120+
if newd.exists || lastd.initial.validFor.firstPhaseId <= ctx.phaseId then
121+
lastDenot = newd
122+
else
122123
// We are trying to bring forward a symbol that is defined only at a later phase
123124
// (typically, a nested Java class, invisible before erasure).
124-
// In that case, keep the checked period to the previous validity, which
125-
// means we will try another bring forward when the symbol is referenced
126-
// at a later phase. Otherwise we'd get stuck on NoDenotation here.
125+
// In that case, keep lastDenot as it was and set the checked period to lastDenot's
126+
// previous validity, which means we will try another bring forward when the symbol
127+
// is referenced at a later phase. Otherwise we'd get stuck on NoDenotation here.
127128
// See #15562 and test i15562b in ReplCompilerTests
128-
checkedPeriod = lastd.initial.validFor
129+
checkedPeriod = lastd.validFor
129130
newd
130131
}
131132

0 commit comments

Comments
 (0)