@@ -2266,15 +2266,17 @@ object Types {
22662266 final def symbol (using Context ): Symbol =
22672267 // We can rely on checkedPeriod (unlike in the definition of `denot` below)
22682268 // 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
22702271
22712272 private def computeSymbol (using Context ): Symbol =
2272- designator match {
2273+ val result = designator match
22732274 case sym : Symbol =>
22742275 if (sym.isValidInCurrentRun) sym else denot.symbol
22752276 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
22782280
22792281 /** There is a denotation computed which is valid (somewhere in) the
22802282 * current run.
@@ -2306,18 +2308,16 @@ object Types {
23062308
23072309 def info (using Context ): Type = denot.info
23082310
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 =
23112315 util.Stats .record(" NamedType.denot" )
2312- val now = ctx.period
2316+ val lastd = lastDenotation. asInstanceOf [ Denotation ]
23132317 // Even if checkedPeriod == now we still need to recheck lastDenotation.validFor
23142318 // 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
23192320 else computeDenot
2320- }
23212321
23222322 private def computeDenot (using Context ): Denotation = {
23232323 util.Stats .record(" NamedType.computeDenot" )
@@ -2353,11 +2353,11 @@ object Types {
23532353 lastDenotation match {
23542354 case lastd0 : SingleDenotation =>
23552355 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
23572357 finish(lastd.current)
23582358 else lastd match {
23592359 case lastd : SymDenotation =>
2360- if ( stillValid(lastd) && ( checkedPeriod != Nowhere )) finish(lastd.current)
2360+ if stillValid(lastd) && checkedPeriod.code != NowhereCode then finish(lastd.current)
23612361 else finish(memberDenot(lastd.initial.name, allowPrivate = false ))
23622362 case _ =>
23632363 fromDesignator
0 commit comments