Skip to content

Commit eb993a9

Browse files
committed
Bring back checkedPeriod
1 parent 110dd20 commit eb993a9

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ object Denotations {
237237
final def validFor: Period = myValidFor
238238
final def validFor_=(p: Period): Unit =
239239
myValidFor = p
240+
symbol.setCheckedPeriod(Nowhere): @unchecked
240241

241242
/** Is this denotation different from NoDenotation or an ErrorDenotation? */
242243
def exists: Boolean = true

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,6 +1810,7 @@ object SymDenotations {
18101810

18111811
/** The last denotation of this symbol */
18121812
var lastDenot: SymDenotation = _
1813+
var checkedPeriod: Period = Nowhere
18131814

18141815
/** Overridden in NoSymbol */
18151816
//private[SymDenotations]
@@ -1819,11 +1820,13 @@ object SymDenotations {
18191820
override def hashCode = common.id // for debugging
18201821

18211822
/** The current denotation of this symbol */
1822-
def currentDenot(using Context): SymDenotation =
1823+
def computeDenot(using Context): SymDenotation =
18231824
util.Stats.record("Symbol.denot")
18241825
val valid = validFor.code
1826+
val now = ctx.period
1827+
symbol.setCheckedPeriod(now)
18251828
// Next condition is inlined from Periods.containsSinglePhasePeriod
1826-
if ((valid - ctx.period.code) >>> PhaseWidth) <= (valid & PhaseMask)
1829+
if ((valid - now.code) >>> PhaseWidth) <= (valid & PhaseMask)
18271830
then this
18281831
else recomputeDenot()
18291832

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,23 @@ object Symbols {
113113
private[core] def denot_=(d: SymDenotation): Unit =
114114
util.Stats.record("Symbol.denot_=")
115115
self.lastDenot = d
116+
self.checkedPeriod = Nowhere
116117

117118
/** The current denotation of this symbol */
118119
def denot(using Context): SymDenotation =
119-
self.lastDenot.currentDenot
120+
util.Stats.record("Symbol.denot")
121+
val lastd = self.lastDenot
122+
if self.checkedPeriod.code == ctx.period.code
123+
then lastd
124+
else lastd.computeDenot
120125

121126
private[core] def setLastDenot(d: SymDenotation): SymDenotation =
122127
self.lastDenot = d
123128
d
124129

130+
def setCheckedPeriod(period: Period): Unit =
131+
self.checkedPeriod = period
132+
125133
/** The original denotation of this symbol, without forcing anything */
126134
def originDenotation: SymDenotation = self
127135

0 commit comments

Comments
 (0)