@@ -110,17 +110,28 @@ object Symbols extends SymUtils {
110110 }
111111
112112 private def computeDenot (lastd : SymDenotation )(using Context ): SymDenotation = {
113+ // Written that way so 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
115117 checkedPeriod = now
116- if ( lastd.validFor contains now) lastd else recomputeDenot(lastd)
118+ if lastd.validFor. contains( now) then lastd else recomputeDenot(lastd)
117119 }
118120
119121 /** Overridden in NoSymbol */
120122 protected def recomputeDenot (lastd : SymDenotation )(using Context ): SymDenotation = {
121123 util.Stats .record(" Symbol.recomputeDenot" )
122124 val newd = lastd.current.asInstanceOf [SymDenotation ]
123- lastDenot = newd
125+ if newd.exists || lastd.initial.validFor.firstPhaseId <= ctx.phaseId then
126+ lastDenot = newd
127+ else
128+ // We are trying to bring forward a symbol that is defined only at a later phase
129+ // (typically, a nested Java class, invisible before erasure).
130+ // In that case, keep lastDenot as it was and set the checked period to lastDenot's
131+ // previous validity, which means we will try another bring forward when the symbol
132+ // is referenced at a later phase. Otherwise we'd get stuck on NoDenotation here.
133+ // See #15562 and test i15562b in ReplCompilerTests
134+ checkedPeriod = lastd.validFor
124135 newd
125136 }
126137
@@ -791,7 +802,7 @@ object Symbols extends SymUtils {
791802 cls : ClassSymbol ,
792803 name : TermName = nme.WILDCARD ,
793804 selfInfo : Type = NoType )(using Context ): TermSymbol =
794- newSymbol(cls, name, SelfSymFlags , selfInfo orElse cls.classInfo.selfType, coord = cls.coord)
805+ newSymbol(cls, name, SelfSymFlags , selfInfo. orElse( cls.classInfo.selfType) , coord = cls.coord)
795806
796807 /** Create new type parameters with given owner, names, and flags.
797808 * @param boundsFn A function that, given type refs to the newly created
@@ -958,7 +969,7 @@ object Symbols extends SymUtils {
958969 */
959970 def getPackageClassIfDefined (path : PreName )(using Context ): Symbol =
960971 staticRef(path.toTypeName, isPackage = true , generateStubs = false )
961- .disambiguate(_ is PackageClass ).symbol
972+ .disambiguate(_.is( PackageClass ) ).symbol
962973
963974 def requiredModule (path : PreName )(using Context ): TermSymbol = {
964975 val name = path.toTermName
0 commit comments