@@ -165,8 +165,7 @@ object Types {
165
165
case _ : SingletonType | NoPrefix => true
166
166
case tp : RefinedOrRecType => tp.parent.isStable
167
167
case tp : ExprType => tp.resultType.isStable
168
- case AppliedType (tycon : TypeRef , args : List [Type ])
169
- if defn.isCompiletimeAppliedType(tycon.symbol) && args.forall(_.isStable) => true
168
+ case tp : AppliedType => tp.appliedTypeIsStable
170
169
case tp : AnnotatedType =>
171
170
// NOTE UncheckedStableAnnot was originally meant to be put on fields,
172
171
// not on types. Allowing it on types is a Scala 3 extension. See:
@@ -4162,11 +4161,22 @@ object Types {
4162
4161
// Boolean caches: 0 = uninitialized, -1 = false, 1 = true
4163
4162
private var myStableHash : Byte = 0
4164
4163
private var myGround : Byte = 0
4164
+ private var myIsStable : Boolean = false
4165
+ private var myIsStableComputed : Boolean = false
4166
+
4165
4167
4166
4168
def isGround (acc : TypeAccumulator [Boolean ])(using Context ): Boolean =
4167
4169
if myGround == 0 then myGround = if acc.foldOver(true , this ) then 1 else - 1
4168
4170
myGround > 0
4169
4171
4172
+ def appliedTypeIsStable (using Context ): Boolean =
4173
+ if ! myIsStableComputed then
4174
+ myIsStable = tycon match
4175
+ case tycon : TypeRef => defn.isCompiletimeAppliedType(tycon.symbol) && args.forall(_.isStable)
4176
+ case _ => false
4177
+ myIsStableComputed = true
4178
+ myIsStable
4179
+
4170
4180
override def underlying (using Context ): Type = tycon
4171
4181
4172
4182
override def superType (using Context ): Type =
0 commit comments