@@ -48,40 +48,14 @@ def ccState(using Context): CCState =
4848
4949extension (tree : Tree )
5050
51- /** Map tree with CaptureRef type to its type,
52- * map CapSet^{refs} to the `refs` references,
53- * throw IllegalCaptureRef otherwise
54- */
55- def toCaptureRefs (using Context ): List [CaptureRef ] = tree match
56- // case ReachCapabilityApply(arg) =>
57- // arg.toCaptureRefs.map(_.reach)
58- // case ReadOnlyCapabilityApply(arg) =>
59- // arg.toCaptureRefs.map(_.readOnly)
60- // case CapsOfApply(arg) =>
61- // arg.toCaptureRefs
62- case _ => tree.tpe.dealiasKeepAnnots match
63- case ref : CaptureRef if ref.isTrackableRef =>
64- ref :: Nil
65- case AnnotatedType (parent, ann)
66- if ann.symbol.isRetains && parent.derivesFrom(defn.Caps_CapSet ) =>
67- ann.tree.toCaptureSet.elems.toList
68- case tpe =>
69- throw IllegalCaptureRef (tpe) // if this was compiled from cc syntax, problem should have been reported at Typer
70-
7151 /** Convert a @retains or @retainsByName annotation tree to the capture set it represents.
7252 * For efficience, the result is cached as an Attachment on the tree.
7353 */
7454 def toCaptureSet (using Context ): CaptureSet =
7555 tree.getAttachment(Captures ) match
7656 case Some (refs) => refs
7757 case None =>
78- val refs =
79- tree match
80- case Apply (_ : TypeApply , _) =>
81- CaptureSet (tree.retainedSet.retainedElements* )
82- case _ =>
83- CaptureSet (tree.retainedElems.flatMap(_.toCaptureRefs)* )
84- // println(s"toCaptureSet: $tree -> $refs")
58+ val refs = CaptureSet (tree.retainedSet.retainedElements* )
8559 tree.putAttachment(Captures , refs)
8660 refs
8761
0 commit comments