@@ -110,17 +110,28 @@ object Symbols extends SymUtils {
110
110
}
111
111
112
112
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)
113
115
util.Stats .record(" Symbol.computeDenot" )
114
116
val now = ctx.period
115
117
checkedPeriod = now
116
- if ( lastd.validFor contains now) lastd else recomputeDenot(lastd)
118
+ if lastd.validFor. contains( now) then lastd else recomputeDenot(lastd)
117
119
}
118
120
119
121
/** Overridden in NoSymbol */
120
122
protected def recomputeDenot (lastd : SymDenotation )(using Context ): SymDenotation = {
121
123
util.Stats .record(" Symbol.recomputeDenot" )
122
124
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
124
135
newd
125
136
}
126
137
@@ -791,7 +802,7 @@ object Symbols extends SymUtils {
791
802
cls : ClassSymbol ,
792
803
name : TermName = nme.WILDCARD ,
793
804
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)
795
806
796
807
/** Create new type parameters with given owner, names, and flags.
797
808
* @param boundsFn A function that, given type refs to the newly created
@@ -958,7 +969,7 @@ object Symbols extends SymUtils {
958
969
*/
959
970
def getPackageClassIfDefined (path : PreName )(using Context ): Symbol =
960
971
staticRef(path.toTypeName, isPackage = true , generateStubs = false )
961
- .disambiguate(_ is PackageClass ).symbol
972
+ .disambiguate(_.is( PackageClass ) ).symbol
962
973
963
974
def requiredModule (path : PreName )(using Context ): TermSymbol = {
964
975
val name = path.toTermName
0 commit comments