Skip to content

Commit fb18037

Browse files
oderskydwijnand
authored andcommitted
Avoid setting lastDenot to NoDenotation in the forward reference scenario
This brings back an element of the original solution. (cherry picked from commit 5631d76)
1 parent 57c4127 commit fb18037

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

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

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

0 commit comments

Comments
 (0)