@@ -151,24 +151,37 @@ extension (tp: Type)
151
151
case tp : ObjectCapability => tp.captureSetOfInfo
152
152
case _ => CaptureSet .ofType(tp, followResult = false )
153
153
154
- /** The deep capture set of a type. This is by default the union of all
154
+ /** Compute a captureset by traversing parts of this type. This is by default the union of all
155
155
* covariant capture sets embedded in the widened type, as computed by
156
156
* `CaptureSet.ofTypeDeeply`. If that set is nonempty, and the type is
157
157
* a singleton capability `x` or a reach capability `x*`, the deep capture
158
158
* set can be narrowed to`{x*}`.
159
+ * @param includeTypevars if true, return a new FreshCap for every type parameter
160
+ * or abstract type with an Any upper bound. Types with
161
+ * defined upper bound are always mapped to the dcs of their bound
162
+ * @param includeBoxed if true, include capture sets found in boxed parts of this type
159
163
*/
160
- def deepCaptureSet (includeTypevars : Boolean , includeBoxed : Boolean = true )(using Context ): CaptureSet =
164
+ def computeDeepCaptureSet (includeTypevars : Boolean , includeBoxed : Boolean = true )(using Context ): CaptureSet =
161
165
val dcs = CaptureSet .ofTypeDeeply(tp.widen.stripCapturing, includeTypevars, includeBoxed)
162
166
if dcs.isAlwaysEmpty then tp.captureSet
163
167
else tp match
164
168
case tp : ObjectCapability if tp.isTrackableRef => tp.reach.singletonCaptureSet
165
169
case _ => tp.captureSet ++ dcs
166
170
171
+ /** The deep capture set of a type. This is by default the union of all
172
+ * covariant capture sets embedded in the widened type, as computed by
173
+ * `CaptureSet.ofTypeDeeply`. If that set is nonempty, and the type is
174
+ * a singleton capability `x` or a reach capability `x*`, the deep capture
175
+ * set can be narrowed to`{x*}`.
176
+ */
167
177
def deepCaptureSet (using Context ): CaptureSet =
168
- deepCaptureSet (includeTypevars = false )
178
+ computeDeepCaptureSet (includeTypevars = false )
169
179
180
+ /** The span capture set of a type. This is analogous to deepCaptureSet but ignoring
181
+ * capture sets in boxed parts.
182
+ */
170
183
def spanCaptureSet (using Context ): CaptureSet =
171
- deepCaptureSet (includeTypevars = false , includeBoxed = false )
184
+ computeDeepCaptureSet (includeTypevars = false , includeBoxed = false )
172
185
173
186
/** A type capturing `ref` */
174
187
def capturing (ref : Capability )(using Context ): Type =
0 commit comments