From 0a5da7363fae5d300e609e3109c01458ca3117a9 Mon Sep 17 00:00:00 2001 From: odersky Date: Mon, 26 Feb 2024 15:58:30 +0100 Subject: [PATCH] Avoid setting lastDenot to NoDenotation in the forward reference scenario This brings back an element of the original solution. --- compiler/src/dotty/tools/dotc/core/Symbols.scala | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/Symbols.scala b/compiler/src/dotty/tools/dotc/core/Symbols.scala index 1cd4d5f86d05..53363baeb5b4 100644 --- a/compiler/src/dotty/tools/dotc/core/Symbols.scala +++ b/compiler/src/dotty/tools/dotc/core/Symbols.scala @@ -122,13 +122,14 @@ object Symbols extends SymUtils { 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 newd