@@ -2097,7 +2097,6 @@ object Types {
2097
2097
private var lastDenotation : Denotation | Null = null
2098
2098
private var lastSymbol : Symbol | Null = null
2099
2099
private var checkedPeriod : Period = Nowhere
2100
- private var firstValidPhaseId : Int = 0
2101
2100
private var myStableHash : Byte = 0
2102
2101
private var mySignature : Signature = _
2103
2102
private var mySignatureRunId : Int = NoRunId
@@ -2213,8 +2212,6 @@ object Types {
2213
2212
val now = ctx.period
2214
2213
// Even if checkedPeriod == now we still need to recheck lastDenotation.validFor
2215
2214
// as it may have been mutated by SymDenotation#installAfter
2216
- if firstValidPhaseId > now.phaseId then
2217
- revalidateDenot()
2218
2215
if (checkedPeriod != Nowhere && lastDenotation.nn.validFor.contains(now)) {
2219
2216
checkedPeriod = now
2220
2217
lastDenotation.nn
@@ -2343,18 +2340,6 @@ object Types {
2343
2340
def recomputeDenot ()(using Context ): Unit =
2344
2341
setDenot(memberDenot(name, allowPrivate = ! symbol.exists || symbol.is(Private )))
2345
2342
2346
- /** Try to recompute denotation and reset `firstValidPhaseId`.
2347
- * @pre Current phase id < firstValidPhaseId
2348
- */
2349
- def revalidateDenot ()(using Context ): Unit =
2350
- if (prefix ne NoPrefix ) then
2351
- core.println(i " revalidate $prefix . $name, $firstValidPhaseId > ${ctx.phaseId}" )
2352
- val newDenot = memberDenot(name, allowPrivate =
2353
- lastSymbol == null || ! lastSymbol.nn.exists || lastSymbol.nn.is(Private ))
2354
- if newDenot.exists then
2355
- setDenot(newDenot)
2356
- firstValidPhaseId = ctx.phaseId
2357
-
2358
2343
private def setDenot (denot : Denotation )(using Context ): Unit = {
2359
2344
if (Config .checkNoDoubleBindings)
2360
2345
if (ctx.settings.YnoDoubleBindings .value)
@@ -2576,7 +2561,7 @@ object Types {
2576
2561
* A test case is neg/opaque-self-encoding.scala.
2577
2562
*/
2578
2563
final def withDenot (denot : Denotation )(using Context ): ThisType =
2579
- if ( denot.exists) {
2564
+ if denot.exists then
2580
2565
val adapted = withSym(denot.symbol)
2581
2566
val result =
2582
2567
if (adapted.eq(this )
@@ -2586,17 +2571,24 @@ object Types {
2586
2571
adapted
2587
2572
else this
2588
2573
val lastDenot = result.lastDenotation
2589
- if denot.isInstanceOf [SymDenotation ] && lastDenot != null && ! lastDenot.isInstanceOf [SymDenotation ] then
2590
- // In this case the new SymDenotation might be valid for all phases, which means
2591
- // we would not recompute the denotation when travelling to an earlier phase, maybe
2592
- // in the next run. We fix that problem by recording in this case in the NamedType
2593
- // the phase from which the denotation is valid. Taking the denotation at an earlier
2594
- // phase will then lead to a `revalidateDenot`.
2595
- core.println(i " overwrite ${result.toString} / ${result.lastDenotation} with $denot" )
2596
- result.firstValidPhaseId = ctx.phaseId
2597
- result.setDenot(denot)
2574
+ denot match
2575
+ case denot : SymDenotation
2576
+ if denot.validFor.firstPhaseId < ctx.phase.id
2577
+ && lastDenot != null
2578
+ && lastDenot.validFor.lastPhaseId > denot.validFor.firstPhaseId
2579
+ && ! lastDenot.isInstanceOf [SymDenotation ] =>
2580
+ // In this case the new SymDenotation might be valid for all phases, which means
2581
+ // we would not recompute the denotation when travelling to an earlier phase, maybe
2582
+ // in the next run. We fix that problem by creating a UniqueRefDenotation instead.
2583
+ core.println(i " overwrite ${result.toString} / ${result.lastDenotation}, ${result.lastDenotation.getClass} with $denot at ${ctx.phaseId}" )
2584
+ result.setDenot(
2585
+ UniqueRefDenotation (
2586
+ denot.symbol, denot.info,
2587
+ Period (ctx.runId, ctx.phaseId, denot.validFor.lastPhaseId),
2588
+ this .prefix))
2589
+ case _ =>
2590
+ result.setDenot(denot)
2598
2591
result.asInstanceOf [ThisType ]
2599
- }
2600
2592
else // don't assign NoDenotation, we might need to recover later. Test case is pos/avoid.scala.
2601
2593
this
2602
2594
0 commit comments