@@ -2313,7 +2313,11 @@ object Types extends TypeUtils {
2313
2313
2314
2314
override def captureSet (using Context ): CaptureSet =
2315
2315
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
2317
2321
2318
2322
end CaptureRef
2319
2323
@@ -3032,7 +3036,7 @@ object Types extends TypeUtils {
3032
3036
3033
3037
abstract case class TypeRef (override val prefix : Type ,
3034
3038
private var myDesignator : Designator )
3035
- extends NamedType {
3039
+ extends NamedType , CaptureRef {
3036
3040
3037
3041
type ThisType = TypeRef
3038
3042
type ThisName = TypeName
@@ -3081,6 +3085,9 @@ object Types extends TypeUtils {
3081
3085
/** Hook that can be called from creation methods in TermRef and TypeRef */
3082
3086
def validated (using Context ): this .type =
3083
3087
this
3088
+
3089
+ override def isTrackableRef (using Context ) =
3090
+ symbol.isAbstractOrParamType && derivesFrom(defn.Caps_CapSet )
3084
3091
}
3085
3092
3086
3093
final class CachedTermRef (prefix : Type , designator : Designator , hc : Int ) extends TermRef (prefix, designator) {
@@ -4841,7 +4848,8 @@ object Types extends TypeUtils {
4841
4848
/** Only created in `binder.paramRefs`. Use `binder.paramRefs(paramNum)` to
4842
4849
* refer to `TypeParamRef(binder, paramNum)`.
4843
4850
*/
4844
- abstract case class TypeParamRef (binder : TypeLambda , paramNum : Int ) extends ParamRef {
4851
+ abstract case class TypeParamRef (binder : TypeLambda , paramNum : Int )
4852
+ extends ParamRef , CaptureRef {
4845
4853
type BT = TypeLambda
4846
4854
def kindString : String = " Type"
4847
4855
def copyBoundType (bt : BT ): Type = bt.paramRefs(paramNum)
@@ -4861,6 +4869,8 @@ object Types extends TypeUtils {
4861
4869
case bound : OrType => occursIn(bound.tp1, fromBelow) || occursIn(bound.tp2, fromBelow)
4862
4870
case _ => false
4863
4871
}
4872
+
4873
+ override def isTrackableRef (using Context ) = derivesFrom(defn.Caps_CapSet )
4864
4874
}
4865
4875
4866
4876
private final class TypeParamRefImpl (binder : TypeLambda , paramNum : Int ) extends TypeParamRef (binder, paramNum)
0 commit comments