@@ -2313,7 +2313,11 @@ object Types extends TypeUtils {
23132313
23142314 override def captureSet (using Context ): CaptureSet =
23152315 val cs = captureSetOfInfo
2316- if isTrackableRef && ! cs.isAlwaysEmpty then singletonCaptureSet else cs
2316+ if isTrackableRef then
2317+ if cs.isAlwaysEmpty then cs else singletonCaptureSet
2318+ else dealias match
2319+ case _ : (TypeRef | TypeParamRef ) => CaptureSet .empty
2320+ case _ => cs
23172321
23182322 end CaptureRef
23192323
@@ -3032,7 +3036,7 @@ object Types extends TypeUtils {
30323036
30333037 abstract case class TypeRef (override val prefix : Type ,
30343038 private var myDesignator : Designator )
3035- extends NamedType {
3039+ extends NamedType , CaptureRef {
30363040
30373041 type ThisType = TypeRef
30383042 type ThisName = TypeName
@@ -3081,6 +3085,9 @@ object Types extends TypeUtils {
30813085 /** Hook that can be called from creation methods in TermRef and TypeRef */
30823086 def validated (using Context ): this .type =
30833087 this
3088+
3089+ override def isTrackableRef (using Context ) =
3090+ symbol.isAbstractOrParamType && derivesFrom(defn.Caps_CapSet )
30843091 }
30853092
30863093 final class CachedTermRef (prefix : Type , designator : Designator , hc : Int ) extends TermRef (prefix, designator) {
@@ -4841,7 +4848,8 @@ object Types extends TypeUtils {
48414848 /** Only created in `binder.paramRefs`. Use `binder.paramRefs(paramNum)` to
48424849 * refer to `TypeParamRef(binder, paramNum)`.
48434850 */
4844- abstract case class TypeParamRef (binder : TypeLambda , paramNum : Int ) extends ParamRef {
4851+ abstract case class TypeParamRef (binder : TypeLambda , paramNum : Int )
4852+ extends ParamRef , CaptureRef {
48454853 type BT = TypeLambda
48464854 def kindString : String = " Type"
48474855 def copyBoundType (bt : BT ): Type = bt.paramRefs(paramNum)
@@ -4861,6 +4869,8 @@ object Types extends TypeUtils {
48614869 case bound : OrType => occursIn(bound.tp1, fromBelow) || occursIn(bound.tp2, fromBelow)
48624870 case _ => false
48634871 }
4872+
4873+ override def isTrackableRef (using Context ) = derivesFrom(defn.Caps_CapSet )
48644874 }
48654875
48664876 private final class TypeParamRefImpl (binder : TypeLambda , paramNum : Int ) extends TypeParamRef (binder, paramNum)
0 commit comments