@@ -434,12 +434,16 @@ object Symbols {
434
434
private [this ] var lastDenot : SymDenotation = _
435
435
private [this ] var checkedPeriod : Period = Nowhere
436
436
437
+ private [this ] var cachedValidFor : Period = _
437
438
private [this ] var cachedName : Name = _
438
439
private [this ] var cachedOwner : Symbol = _
439
440
private [this ] var cachedInfo : Type = _
440
441
private [this ] var cachedFlags : FlagSet = _
441
442
442
- private [core] def invalidateDenotCache () = { checkedPeriod = Nowhere }
443
+ private [core] def updateValidForCache (d : Denotation , validFor : Period ) = {
444
+ if (lastDenot `eq` d) cachedValidFor = validFor
445
+ checkedPeriod = Nowhere // this forces recomputeDenot() on next call to denot
446
+ }
443
447
444
448
private [core] def updateInfoCache (d : SymDenotation , info : Type ) =
445
449
if (lastDenot `eq` d) cachedInfo = info
@@ -449,6 +453,7 @@ object Symbols {
449
453
450
454
private [this ] def setLastDenot (d : SymDenotation ) = {
451
455
lastDenot = d
456
+ cachedValidFor = d.validFor
452
457
cachedName = d.name
453
458
cachedOwner = d.maybeOwner
454
459
cachedInfo = d.infoOrCompleter
@@ -464,22 +469,21 @@ object Symbols {
464
469
/** The current denotation of this symbol */
465
470
final def denot (implicit ctx : Context ): SymDenotation = {
466
471
Stats .record(" Symbol.denot" )
467
- val lastd = lastDenot
468
- if (checkedPeriod == ctx.period) lastd
469
- else computeDenot(lastd)
472
+ if (checkedPeriod == ctx.period) lastDenot
473
+ else computeDenot()
470
474
}
471
475
472
- private def computeDenot (lastd : SymDenotation )(implicit ctx : Context ): SymDenotation = {
476
+ private def computeDenot ()(implicit ctx : Context ): SymDenotation = {
473
477
Stats .record(" Symbol.computeDenot" )
474
478
val now = ctx.period
475
479
checkedPeriod = now
476
- if (lastd.validFor contains now) lastd else recomputeDenot(lastd )
480
+ if (cachedValidFor contains now) lastDenot else recomputeDenot()
477
481
}
478
482
479
483
/** Overridden in NoSymbol */
480
- protected def recomputeDenot (lastd : SymDenotation )(implicit ctx : Context ) = {
484
+ protected def recomputeDenot ()(implicit ctx : Context ) = {
481
485
Stats .record(" Symbol.recomputeDenot" )
482
- val newd = lastd .current.asInstanceOf [SymDenotation ]
486
+ val newd = lastDenot .current.asInstanceOf [SymDenotation ]
483
487
setLastDenot(newd)
484
488
newd
485
489
}
@@ -638,7 +642,7 @@ object Symbols {
638
642
// -------- Cached SymDenotation facades -----------------------------------------------
639
643
640
644
private def ensureUpToDate ()(implicit ctx : Context ) =
641
- if (checkedPeriod != ctx.period) computeDenot(lastDenot )
645
+ if (checkedPeriod != ctx.period) computeDenot()
642
646
643
647
/** The current name of this symbol */
644
648
final def name (implicit ctx : Context ): ThisName = {
@@ -893,7 +897,7 @@ object Symbols {
893
897
@ sharable val NoSymbol : Symbol = new Symbol (NoCoord , 0 ) {
894
898
override def owner (implicit ctx : Context ): Symbol = throw new AssertionError (" NoSymbol.owner" )
895
899
override def associatedFile (implicit ctx : Context ): AbstractFile = NoSource .file
896
- override def recomputeDenot (lastd : SymDenotation )(implicit ctx : Context ): SymDenotation = NoDenotation
900
+ override def recomputeDenot ()(implicit ctx : Context ): SymDenotation = NoDenotation
897
901
}
898
902
899
903
NoDenotation // force it in order to set `denot` field of NoSymbol
0 commit comments