@@ -73,7 +73,7 @@ extension (tp: Type)
73
73
then tp
74
74
else tp.boxed
75
75
76
- /** The capture set of `tp` consisting of all top-level captures under a box.
76
+ /** The capture set consisting of all top-level captures of `tp` that appear under a box.
77
77
* Unlike for `boxed` this also considers parents of capture types, unions and
78
78
* intersections, and type proxies other than abstract types.
79
79
*/
@@ -89,8 +89,12 @@ extension (tp: Type)
89
89
case _ => CaptureSet .empty
90
90
getBoxed(tp)
91
91
92
+ /** Is the boxedCaptureSet of this type nonempty? */
92
93
def isBoxedCapturing (using Context ) = ! tp.boxedCaptureSet.isAlwaysEmpty
93
94
95
+ /** Map capturing type to their parents. Capturing types accessible
96
+ * via dealising are also stripped.
97
+ */
94
98
def stripCapturing (using Context ): Type = tp.dealiasKeepAnnots match
95
99
case CapturingType (parent, _) =>
96
100
parent.stripCapturing
@@ -138,11 +142,15 @@ extension (sym: Symbol)
138
142
&& ! sym.allowsRootCapture
139
143
140
144
extension (tp : AnnotatedType )
145
+ /** Is this a boxed capturing type? */
141
146
def isBoxed (using Context ): Boolean = tp.annot match
142
147
case ann : CaptureAnnotation => ann.boxed
143
148
case _ => false
144
149
145
150
extension (ts : List [Type ])
151
+ /** Equivalent to ts.mapconserve(_.boxedUnlessFun(tycon)) but more efficient where
152
+ * it is the identity.
153
+ */
146
154
def boxedUnlessFun (tycon : Type )(using Context ) =
147
155
if ctx.phase != Phases .checkCapturesPhase || defn.isFunctionClass(tycon.typeSymbol)
148
156
then ts
0 commit comments