@@ -47,28 +47,6 @@ def ccState(using Context): CCState =
4747
4848extension (tree : Tree )
4949
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-
7250 /** Convert a @retains or @retainsByName annotation tree to the capture set it represents.
7351 * For efficience, the result is cached as an Attachment on the tree.
7452 */
@@ -79,6 +57,7 @@ extension (tree: Tree)
7957 val refs = CaptureSet (tree.retainedSet.retainedElements* )
8058 tree.putAttachment(Captures , refs)
8159 refs
60+
8261 /** The type representing the capture set of retains annotation.
8362 */
8463 def retainedSet (using Context ): Type =
@@ -561,11 +540,16 @@ end AnnotatedCapability
561540 */
562541object ReadOnlyCapability extends AnnotatedCapability (defn.ReadOnlyCapabilityAnnot )
563542
564- /** An extractor for `ref @annotation.internal. reachCapability`, which is used to express
543+ /** An extractor for `ref @reachCapability`, which is used to express
565544 * the reach capability `ref*` as a type.
566545 */
567546object ReachCapability extends AnnotatedCapability (defn.ReachCapabilityAnnot )
568547
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+
569553/** An extractor for all kinds of function types as well as method and poly types.
570554 * It includes aliases of function types such as `=>`. TODO: Can we do without?
571555 * @return 1st half: The argument types or empty if this is a type function
0 commit comments