File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -175,7 +175,7 @@ object Types {
175175 // see: tests/explicit-nulls/pos/flow-stable.scala.disabled
176176 tp.tp1.isStable && (realizability(tp.tp2) eq Realizable ) ||
177177 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
179179 case _ => false
180180 }
181181
@@ -4162,10 +4162,25 @@ object Types {
41624162 private var myStableHash : Byte = 0
41634163 private var myGround : Byte = 0
41644164
4165+ private var myIsStablePeriod : Period = Nowhere
4166+ private var myIsStable : Boolean = false
4167+
41654168 def isGround (acc : TypeAccumulator [Boolean ])(using Context ): Boolean =
41664169 if myGround == 0 then myGround = if acc.foldOver(true , this ) then 1 else - 1
41674170 myGround > 0
41684171
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+
41694184 override def underlying (using Context ): Type = tycon
41704185
41714186 override def superType (using Context ): Type =
You can’t perform that action at this time.
0 commit comments