@@ -2263,15 +2263,17 @@ object Types {
2263
2263
final def symbol (using Context ): Symbol =
2264
2264
// We can rely on checkedPeriod (unlike in the definition of `denot` below)
2265
2265
// because SymDenotation#installAfter never changes the symbol
2266
- if (checkedPeriod == ctx.period) lastSymbol.nn else computeSymbol
2266
+ if (checkedPeriod == ctx.period) lastSymbol.asInstanceOf [Symbol ]
2267
+ else computeSymbol
2267
2268
2268
2269
private def computeSymbol (using Context ): Symbol =
2269
- designator match {
2270
+ val result = designator match
2270
2271
case sym : Symbol =>
2271
2272
if (sym.isValidInCurrentRun) sym else denot.symbol
2272
2273
case name =>
2273
- (if (denotationIsCurrent) lastDenotation.nn else denot).symbol
2274
- }
2274
+ (if (denotationIsCurrent) lastDenotation.asInstanceOf [Denotation ] else denot).symbol
2275
+ if checkedPeriod.exists then checkedPeriod = ctx.period
2276
+ result
2275
2277
2276
2278
/** There is a denotation computed which is valid (somewhere in) the
2277
2279
* current run.
@@ -2303,18 +2305,16 @@ object Types {
2303
2305
2304
2306
def info (using Context ): Type = denot.info
2305
2307
2306
- /** The denotation currently denoted by this type */
2307
- final def denot (using Context ): Denotation = {
2308
+ /** The denotation currently denoted by this type. Extremely hot. Carefully optimized
2309
+ * to be as small as possible.
2310
+ */
2311
+ final def denot (using Context ): Denotation =
2308
2312
util.Stats .record(" NamedType.denot" )
2309
- val now = ctx.period
2313
+ val lastd = lastDenotation. asInstanceOf [ Denotation ]
2310
2314
// Even if checkedPeriod == now we still need to recheck lastDenotation.validFor
2311
2315
// as it may have been mutated by SymDenotation#installAfter
2312
- if (checkedPeriod != Nowhere && lastDenotation.nn.validFor.contains(now)) {
2313
- checkedPeriod = now
2314
- lastDenotation.nn
2315
- }
2316
+ if checkedPeriod.code != NowhereCode && lastd.validFor.contains(ctx.period) then lastd
2316
2317
else computeDenot
2317
- }
2318
2318
2319
2319
private def computeDenot (using Context ): Denotation = {
2320
2320
util.Stats .record(" NamedType.computeDenot" )
@@ -2350,11 +2350,11 @@ object Types {
2350
2350
lastDenotation match {
2351
2351
case lastd0 : SingleDenotation =>
2352
2352
val lastd = lastd0.skipRemoved
2353
- if lastd.validFor.runId == ctx.runId && checkedPeriod != Nowhere then
2353
+ if lastd.validFor.runId == ctx.runId && checkedPeriod.exists then
2354
2354
finish(lastd.current)
2355
2355
else lastd match {
2356
2356
case lastd : SymDenotation =>
2357
- if ( stillValid(lastd) && ( checkedPeriod != Nowhere )) finish(lastd.current)
2357
+ if stillValid(lastd) && checkedPeriod.exists then finish(lastd.current)
2358
2358
else finish(memberDenot(lastd.initial.name, allowPrivate = false ))
2359
2359
case _ =>
2360
2360
fromDesignator
0 commit comments