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