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