@@ -2163,7 +2163,7 @@ object Types {
2163
2163
}
2164
2164
2165
2165
/** A trait for references in CaptureSets. These can be NamedTypes, ThisTypes or ParamRefs */
2166
- trait CaptureRef extends SingletonType :
2166
+ trait CaptureRef extends TypeProxy , ValueType :
2167
2167
private var myCaptureSet : CaptureSet | Null = uninitialized
2168
2168
private var myCaptureSetRunId : Int = NoRunId
2169
2169
private var mySingletonCaptureSet : CaptureSet .Const | Null = null
@@ -2175,9 +2175,9 @@ object Types {
2175
2175
isTrackableRef && (isRootCapability || ! captureSetOfInfo.isAlwaysEmpty)
2176
2176
2177
2177
/** Is this a reach reference of the form `x*`? */
2178
- def isReach (using Context ): Boolean = false // overridden in TermRef
2178
+ def isReach (using Context ): Boolean = false // overridden in AnnotatedType
2179
2179
2180
- def stripReach (using Context ): CaptureRef = this // overridden in TermRef
2180
+ def stripReach (using Context ): CaptureRef = this // overridden in AnnotatedType
2181
2181
2182
2182
/** Is this reference the generic root capability `cap` ? */
2183
2183
def isRootCapability (using Context ): Boolean = false
@@ -2214,6 +2214,8 @@ object Types {
2214
2214
2215
2215
end CaptureRef
2216
2216
2217
+ trait SingletonCaptureRef extends SingletonType , CaptureRef
2218
+
2217
2219
/** A trait for types that bind other types that refer to them.
2218
2220
* Instances are: LambdaType, RecType.
2219
2221
*/
@@ -2877,7 +2879,7 @@ object Types {
2877
2879
*/
2878
2880
abstract case class TermRef (override val prefix : Type ,
2879
2881
private var myDesignator : Designator )
2880
- extends NamedType , ImplicitRef , CaptureRef {
2882
+ extends NamedType , ImplicitRef , SingletonCaptureRef {
2881
2883
2882
2884
type ThisType = TermRef
2883
2885
type ThisName = TermName
@@ -2913,21 +2915,12 @@ object Types {
2913
2915
|| symbol.is(ParamAccessor ) && (prefix eq symbol.owner.thisType)
2914
2916
|| isRootCapability
2915
2917
) && ! symbol.isOneOf(UnstableValueFlags )
2916
- || isReach
2917
-
2918
- override def isReach (using Context ): Boolean =
2919
- name == nme.CC_REACH && symbol == defn.Any_ccReach
2920
-
2921
- override def stripReach (using Context ): CaptureRef =
2922
- if isReach then prefix.asInstanceOf [CaptureRef ] else this
2923
2918
2924
2919
override def isRootCapability (using Context ): Boolean =
2925
2920
name == nme.CAPTURE_ROOT && symbol == defn.captureRoot
2926
2921
2927
2922
override def normalizedRef (using Context ): CaptureRef =
2928
- if isReach then TermRef (stripReach.normalizedRef, name, denot)
2929
- else if isTrackableRef then symbol.termRef
2930
- else this
2923
+ if isTrackableRef then symbol.termRef else this
2931
2924
}
2932
2925
2933
2926
abstract case class TypeRef (override val prefix : Type ,
@@ -3066,7 +3059,8 @@ object Types {
3066
3059
* Note: we do not pass a class symbol directly, because symbols
3067
3060
* do not survive runs whereas typerefs do.
3068
3061
*/
3069
- abstract case class ThisType (tref : TypeRef ) extends CachedProxyType , CaptureRef {
3062
+ abstract case class ThisType (tref : TypeRef )
3063
+ extends CachedProxyType , SingletonCaptureRef {
3070
3064
def cls (using Context ): ClassSymbol = tref.stableInRunSymbol match {
3071
3065
case cls : ClassSymbol => cls
3072
3066
case _ if ctx.mode.is(Mode .Interactive ) => defn.AnyClass // was observed to happen in IDE mode
@@ -4679,7 +4673,8 @@ object Types {
4679
4673
/** Only created in `binder.paramRefs`. Use `binder.paramRefs(paramNum)` to
4680
4674
* refer to `TermParamRef(binder, paramNum)`.
4681
4675
*/
4682
- abstract case class TermParamRef (binder : TermLambda , paramNum : Int ) extends ParamRef , CaptureRef {
4676
+ abstract case class TermParamRef (binder : TermLambda , paramNum : Int )
4677
+ extends ParamRef , SingletonCaptureRef {
4683
4678
type BT = TermLambda
4684
4679
def kindString : String = " Term"
4685
4680
def copyBoundType (bt : BT ): Type = bt.paramRefs(paramNum)
@@ -5386,7 +5381,7 @@ object Types {
5386
5381
// ----- Annotated and Import types -----------------------------------------------
5387
5382
5388
5383
/** An annotated type tpe @ annot */
5389
- abstract case class AnnotatedType (parent : Type , annot : Annotation ) extends CachedProxyType , ValueType {
5384
+ abstract case class AnnotatedType (parent : Type , annot : Annotation ) extends CachedProxyType , CaptureRef {
5390
5385
5391
5386
override def underlying (using Context ): Type = parent
5392
5387
@@ -5415,6 +5410,23 @@ object Types {
5415
5410
isRefiningCache
5416
5411
}
5417
5412
5413
+ override def isTrackableRef (using Context ) =
5414
+ isReach && parent.isTrackableRef
5415
+
5416
+ /** Is this a reach reference of the form `x*`? */
5417
+ override def isReach (using Context ): Boolean =
5418
+ annot.symbol == defn.ReachCapabilityAnnot
5419
+
5420
+ override def stripReach (using Context ): SingletonCaptureRef =
5421
+ (if isReach then parent else this ).asInstanceOf [SingletonCaptureRef ]
5422
+
5423
+ override def normalizedRef (using Context ): CaptureRef =
5424
+ if isReach then AnnotatedType (stripReach.normalizedRef, annot) else this
5425
+
5426
+ override def captureSet (using Context ): CaptureSet =
5427
+ if isReach then super .captureSet
5428
+ else CaptureSet .ofType(this , followResult = false )
5429
+
5418
5430
// equals comes from case class; no matching override is needed
5419
5431
5420
5432
override def computeHash (bs : Binders ): Int =
0 commit comments