@@ -47,28 +47,6 @@ def ccState(using Context): CCState =
47
47
48
48
extension (tree : Tree )
49
49
50
- /** Map tree with a Capability type to the corresponding capability,
51
- * map CapSet^{refs} to the `refs` references,
52
- * throw IllegalCaptureRef otherwise
53
- */
54
- // def toCapabilities(using Context): List[Capability] = tree match
55
- // case ReachCapabilityApply(arg) =>
56
- // arg.toCapabilities.map(_.reach)
57
- // case ReadOnlyCapabilityApply(arg) =>
58
- // arg.toCapabilities.map(_.readOnly)
59
- // case CapsOfApply(arg) =>
60
- // arg.toCapabilities
61
- // case _ => tree.tpe.dealiasKeepAnnots match
62
- // case ref: TermRef if ref.isCapRef =>
63
- // GlobalCap :: Nil
64
- // case ref: Capability if ref.isTrackableRef =>
65
- // ref :: Nil
66
- // case AnnotatedType(parent, ann)
67
- // if ann.symbol.isRetains && parent.derivesFrom(defn.Caps_CapSet) =>
68
- // ann.tree.toCaptureSet.elems.toList
69
- // case tpe =>
70
- // throw IllegalCaptureRef(tpe) // if this was compiled from cc syntax, problem should have been reported at Typer
71
-
72
50
/** Convert a @retains or @retainsByName annotation tree to the capture set it represents.
73
51
* For efficience, the result is cached as an Attachment on the tree.
74
52
*/
@@ -79,6 +57,7 @@ extension (tree: Tree)
79
57
val refs = CaptureSet (tree.retainedSet.retainedElements* )
80
58
tree.putAttachment(Captures , refs)
81
59
refs
60
+
82
61
/** The type representing the capture set of retains annotation.
83
62
*/
84
63
def retainedSet (using Context ): Type =
@@ -561,11 +540,16 @@ end AnnotatedCapability
561
540
*/
562
541
object ReadOnlyCapability extends AnnotatedCapability (defn.ReadOnlyCapabilityAnnot )
563
542
564
- /** An extractor for `ref @annotation.internal. reachCapability`, which is used to express
543
+ /** An extractor for `ref @reachCapability`, which is used to express
565
544
* the reach capability `ref*` as a type.
566
545
*/
567
546
object ReachCapability extends AnnotatedCapability (defn.ReachCapabilityAnnot )
568
547
548
+ /** An extractor for `ref @amaybeCapability`, which is used to express
549
+ * the maybe capability `ref?` as a type.
550
+ */
551
+ object MaybeCapability extends AnnotatedCapability (defn.MaybeCapabilityAnnot )
552
+
569
553
/** An extractor for all kinds of function types as well as method and poly types.
570
554
* It includes aliases of function types such as `=>`. TODO: Can we do without?
571
555
* @return 1st half: The argument types or empty if this is a type function
0 commit comments