Skip to content

Commit 0a5da73

Browse files
committed
Avoid setting lastDenot to NoDenotation in the forward reference scenario
This brings back an element of the original solution.
1 parent e79b2e9 commit 0a5da73

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

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

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

0 commit comments

Comments
 (0)