@@ -110,25 +110,28 @@ object Symbols extends SymUtils {
110110 }
111111
112112 private def computeDenot (lastd : SymDenotation )(using Context ): SymDenotation = {
113+ // Written that way do that it comes in at 32 bytes and is therefore inlineable for
114+ // the JIT (reputedly, cutoff is at 35 bytes)
113115 util.Stats .record(" Symbol.computeDenot" )
114116 val now = ctx.period
115- val prev = checkedPeriod
116117 checkedPeriod = now
117- if lastd.validFor.contains(now) then
118- lastd
119- else
120- val newd = recomputeDenot(lastd)
121- if newd.exists then
122- lastDenot = newd
123- else
124- checkedPeriod = prev
125- newd
118+ if lastd.validFor.contains(now) then lastd else recomputeDenot(lastd)
126119 }
127120
128121 /** Overridden in NoSymbol */
129122 protected def recomputeDenot (lastd : SymDenotation )(using Context ): SymDenotation = {
130123 util.Stats .record(" Symbol.recomputeDenot" )
131- lastd.current.asSymDenotation
124+ val newd = lastd.current.asInstanceOf [SymDenotation ]
125+ lastDenot = newd
126+ if ! newd.exists && lastd.initial.validFor.firstPhaseId > ctx.phaseId then
127+ // We are trying to bring forward a symbol that is defined only at a later phase
128+ // (typically, a nested Java class, invisible before erasure).
129+ // In that case, keep the checked period to the previous validity, which
130+ // means we will try another bring forward when the symbol is referenced
131+ // at a later phase. Otherwise we'd get stuck on NoDenotation here.
132+ // See #15562 and test i15562b in ReplCompilerTests
133+ checkedPeriod = lastd.initial.validFor
134+ newd
132135 }
133136
134137 /** The original denotation of this symbol, without forcing anything */
@@ -798,7 +801,7 @@ object Symbols extends SymUtils {
798801 cls : ClassSymbol ,
799802 name : TermName = nme.WILDCARD ,
800803 selfInfo : Type = NoType )(using Context ): TermSymbol =
801- newSymbol(cls, name, SelfSymFlags , selfInfo orElse cls.classInfo.selfType, coord = cls.coord)
804+ newSymbol(cls, name, SelfSymFlags , selfInfo. orElse( cls.classInfo.selfType) , coord = cls.coord)
802805
803806 /** Create new type parameters with given owner, names, and flags.
804807 * @param boundsFn A function that, given type refs to the newly created
@@ -965,7 +968,7 @@ object Symbols extends SymUtils {
965968 */
966969 def getPackageClassIfDefined (path : PreName )(using Context ): Symbol =
967970 staticRef(path.toTypeName, isPackage = true , generateStubs = false )
968- .disambiguate(_ is PackageClass ).symbol
971+ .disambiguate(_.is( PackageClass ) ).symbol
969972
970973 def requiredModule (path : PreName )(using Context ): TermSymbol = {
971974 val name = path.toTermName
0 commit comments