File tree 1 file changed +16
-1
lines changed
compiler/src/dotty/tools/dotc/core 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -175,7 +175,7 @@ object Types {
175
175
// see: tests/explicit-nulls/pos/flow-stable.scala.disabled
176
176
tp.tp1.isStable && (realizability(tp.tp2) eq Realizable ) ||
177
177
tp.tp2.isStable && (realizability(tp.tp1) eq Realizable )
178
- case AppliedType ( tycon : TypeRef , args) if defn.isCompiletimeAppliedType(tycon.symbol) && args.forall(_.isStable) => true
178
+ case tp : AppliedType => tp.cachedIsStable
179
179
case _ => false
180
180
}
181
181
@@ -4162,10 +4162,25 @@ object Types {
4162
4162
private var myStableHash : Byte = 0
4163
4163
private var myGround : Byte = 0
4164
4164
4165
+ private var myIsStablePeriod : Period = Nowhere
4166
+ private var myIsStable : Boolean = false
4167
+
4165
4168
def isGround (acc : TypeAccumulator [Boolean ])(using Context ): Boolean =
4166
4169
if myGround == 0 then myGround = if acc.foldOver(true , this ) then 1 else - 1
4167
4170
myGround > 0
4168
4171
4172
+ private [Types ] def cachedIsStable (using Context ): Boolean =
4173
+ if myIsStablePeriod != ctx.period then
4174
+ val res = tycon match
4175
+ case tycon : TypeRef if defn.isCompiletimeAppliedType(tycon.symbol) && args.forall(_.isStable) => true
4176
+ case _ => false
4177
+ if ! isProvisional then
4178
+ myIsStablePeriod = ctx.period
4179
+ myIsStable = res
4180
+ res
4181
+ else
4182
+ myIsStable
4183
+
4169
4184
override def underlying (using Context ): Type = tycon
4170
4185
4171
4186
override def superType (using Context ): Type =
You can’t perform that action at this time.
0 commit comments