@@ -38,7 +38,7 @@ def depFun(args: List[Type], resultType: Type, isContextual: Boolean, paramNames
38
38
else make(args, resultType)
39
39
mt.toFunctionType(alwaysDependent = true )
40
40
41
- /** An exception thrown if a @retains argument is not syntactically a CaptureRef */
41
+ /** An exception thrown if a @retains argument is not syntactically a Capability */
42
42
class IllegalCaptureRef (tpe : Type )(using Context ) extends Exception (tpe.show)
43
43
44
44
/** A base trait for data producing addenda to error messages */
@@ -50,21 +50,21 @@ def ccState(using Context): CCState =
50
50
51
51
extension (tree : Tree )
52
52
53
- /** Map tree with CaptureRef type to its type ,
53
+ /** Map tree with a Capability type to the corresponding capability ,
54
54
* map CapSet^{refs} to the `refs` references,
55
55
* throw IllegalCaptureRef otherwise
56
56
*/
57
- def toCaptureRefs (using Context ): List [CaptureRef ] = tree match
57
+ def toCapabilities (using Context ): List [Capability ] = tree match
58
58
case ReachCapabilityApply (arg) =>
59
- arg.toCaptureRefs .map(_.reach)
59
+ arg.toCapabilities .map(_.reach)
60
60
case ReadOnlyCapabilityApply (arg) =>
61
- arg.toCaptureRefs .map(_.readOnly)
61
+ arg.toCapabilities .map(_.readOnly)
62
62
case CapsOfApply (arg) =>
63
- arg.toCaptureRefs
63
+ arg.toCapabilities
64
64
case _ => tree.tpe.dealiasKeepAnnots match
65
65
case ref : TermRef if ref.isCapRef =>
66
66
GlobalCap :: Nil
67
- case ref : CaptureRef if ref.isTrackableRef =>
67
+ case ref : Capability if ref.isTrackableRef =>
68
68
ref :: Nil
69
69
case AnnotatedType (parent, ann)
70
70
if ann.symbol.isRetains && parent.derivesFrom(defn.Caps_CapSet ) =>
@@ -79,7 +79,7 @@ extension (tree: Tree)
79
79
tree.getAttachment(Captures ) match
80
80
case Some (refs) => refs
81
81
case None =>
82
- val refs = CaptureSet (tree.retainedElems.flatMap(_.toCaptureRefs )* )
82
+ val refs = CaptureSet (tree.retainedElems.flatMap(_.toCapabilities )* )
83
83
// .showing(i"toCaptureSet $tree --> $result", capt)
84
84
tree.putAttachment(Captures , refs)
85
85
refs
@@ -95,7 +95,7 @@ extension (tree: Tree)
95
95
96
96
extension (tp : Type )
97
97
98
- /** Is this type a CaptureRef that can be tracked?
98
+ /** Is this type a Capability that can be tracked?
99
99
* This is true for
100
100
* - all ThisTypes and all TermParamRef,
101
101
* - stable TermRefs with NoPrefix or ThisTypes as prefixes,
@@ -120,9 +120,9 @@ extension (tp: Type)
120
120
false
121
121
122
122
/** The capture set of a type. This is:
123
- * - For trackable capture references : The singleton capture set consisting of
123
+ * - For trackable capabilities : The singleton capture set consisting of
124
124
* just the reference, provided the underlying capture set of their info is not empty.
125
- * - For other capture references : The capture set of their info
125
+ * - For other capabilities : The capture set of their info
126
126
* - For all other types: The result of CaptureSet.ofType
127
127
*/
128
128
final def captureSet (using Context ): CaptureSet = tp match
@@ -149,7 +149,7 @@ extension (tp: Type)
149
149
deepCaptureSet(includeTypevars = false )
150
150
151
151
/** A type capturing `ref` */
152
- def capturing (ref : CaptureRef )(using Context ): Type =
152
+ def capturing (ref : Capability )(using Context ): Type =
153
153
if tp.captureSet.accountsFor(ref) then tp
154
154
else CapturingType (tp, ref.singletonCaptureSet)
155
155
@@ -200,7 +200,7 @@ extension (tp: Type)
200
200
/** The capture set consisting of all top-level captures of `tp` that appear under a box.
201
201
* Unlike for `boxed` this also considers parents of capture types, unions and
202
202
* intersections, and type proxies other than abstract types.
203
- * Furthermore, if the original type is a capture ref `x`, it replaces boxed universal sets
203
+ * Furthermore, if the original type is a capability `x`, it replaces boxed universal sets
204
204
* on the fly with x*.
205
205
*/
206
206
def boxedCaptureSet (using Context ): CaptureSet =
@@ -215,7 +215,7 @@ extension (tp: Type)
215
215
pcs ++ reachRef.singletonCaptureSet
216
216
case _ =>
217
217
pcs ++ refs
218
- case ref : CaptureRef if ref.isTracked && ! pre.exists => getBoxed(ref, ref)
218
+ case ref : Capability if ref.isTracked && ! pre.exists => getBoxed(ref, ref)
219
219
case tp : TypeRef if tp.symbol.isAbstractOrParamType => CaptureSet .empty
220
220
case tp : TypeProxy => getBoxed(tp.superType, pre)
221
221
case tp : AndType => getBoxed(tp.tp1, pre) ** getBoxed(tp.tp2, pre)
@@ -249,7 +249,7 @@ extension (tp: Type)
249
249
def forceBoxStatus (boxed : Boolean )(using Context ): Type = tp.widenDealias match
250
250
case tp @ CapturingType (parent, refs) if tp.isBoxed != boxed =>
251
251
val refs1 = tp match
252
- case ref : CaptureRef if ref.isTracked || ref.isReach || ref.isReadOnly =>
252
+ case ref : Capability if ref.isTracked || ref.isReach || ref.isReadOnly =>
253
253
ref.singletonCaptureSet
254
254
case _ => refs
255
255
CapturingType (parent, refs1, boxed)
@@ -347,7 +347,7 @@ extension (tp: Type)
347
347
mapOver(t)
348
348
tm(tp)
349
349
350
- /** If `x` is a capture ref , replace all no-flip covariant occurrences of `cap`
350
+ /** If `x` is a capability , replace all no-flip covariant occurrences of `cap`
351
351
* in type `tp` with `x*`.
352
352
*/
353
353
def withReachCaptures (ref : Type )(using Context ): Type = ref match
@@ -620,9 +620,9 @@ object ContainsImpl:
620
620
621
621
/** An extractor for a contains parameter */
622
622
object ContainsParam :
623
- def unapply (sym : Symbol )(using Context ): Option [(TypeRef , CaptureRef )] =
623
+ def unapply (sym : Symbol )(using Context ): Option [(TypeRef , Capability )] =
624
624
sym.info.dealias match
625
- case AppliedType (tycon, (cs : TypeRef ) :: (ref : CaptureRef ) :: Nil )
625
+ case AppliedType (tycon, (cs : TypeRef ) :: (ref : Capability ) :: Nil )
626
626
if tycon.typeSymbol == defn.Caps_ContainsTrait
627
627
&& cs.typeSymbol.isAbstractOrParamType => Some ((cs, ref))
628
628
case _ => None
0 commit comments