Skip to content

Commit

Permalink
Avoid setting lastDenot to NoDenotation in the forward reference scen…
Browse files Browse the repository at this point in the history
…ario

This brings back an element of the original solution.

(cherry picked from commit 5631d76)
  • Loading branch information
odersky authored and dwijnand committed Mar 5, 2024
1 parent 8b1320c commit 95377aa
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions compiler/src/dotty/tools/dotc/core/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,16 @@ object Symbols {
protected def recomputeDenot(lastd: SymDenotation)(using Context): SymDenotation = {
util.Stats.record("Symbol.recomputeDenot")
val newd = lastd.current.asInstanceOf[SymDenotation]
lastDenot = newd
if !newd.exists && lastd.initial.validFor.firstPhaseId > ctx.phaseId then
if newd.exists || lastd.initial.validFor.firstPhaseId <= ctx.phaseId then
lastDenot = newd
else
// We are trying to bring forward a symbol that is defined only at a later phase
// (typically, a nested Java class, invisible before erasure).
// In that case, keep the checked period to the previous validity, which
// means we will try another bring forward when the symbol is referenced
// at a later phase. Otherwise we'd get stuck on NoDenotation here.
// In that case, keep lastDenot as it was and set the checked period to lastDenot's
// previous validity, which means we will try another bring forward when the symbol
// is referenced at a later phase. Otherwise we'd get stuck on NoDenotation here.
// See #15562 and test i15562b in ReplCompilerTests
checkedPeriod = lastd.initial.validFor
checkedPeriod = lastd.validFor
newd
}

Expand Down

0 comments on commit 95377aa

Please sign in to comment.