@@ -190,40 +190,14 @@ def ccState(using Context): CCState =
190190
191191extension (tree : Tree )
192192
193- /** Map tree with CaptureRef type to its type,
194- * map CapSet^{refs} to the `refs` references,
195- * throw IllegalCaptureRef otherwise
196- */
197- def toCaptureRefs (using Context ): List [CaptureRef ] = tree match
198- // case ReachCapabilityApply(arg) =>
199- // arg.toCaptureRefs.map(_.reach)
200- // case ReadOnlyCapabilityApply(arg) =>
201- // arg.toCaptureRefs.map(_.readOnly)
202- // case CapsOfApply(arg) =>
203- // arg.toCaptureRefs
204- case _ => tree.tpe.dealiasKeepAnnots match
205- case ref : CaptureRef if ref.isTrackableRef =>
206- ref :: Nil
207- case AnnotatedType (parent, ann)
208- if ann.symbol.isRetains && parent.derivesFrom(defn.Caps_CapSet ) =>
209- ann.tree.toCaptureSet.elems.toList
210- case tpe =>
211- throw IllegalCaptureRef (tpe) // if this was compiled from cc syntax, problem should have been reported at Typer
212-
213193 /** Convert a @retains or @retainsByName annotation tree to the capture set it represents.
214194 * For efficience, the result is cached as an Attachment on the tree.
215195 */
216196 def toCaptureSet (using Context ): CaptureSet =
217197 tree.getAttachment(Captures ) match
218198 case Some (refs) => refs
219199 case None =>
220- val refs =
221- tree match
222- case Apply (_ : TypeApply , _) =>
223- CaptureSet (tree.retainedSet.retainedElements* )
224- case _ =>
225- CaptureSet (tree.retainedElems.flatMap(_.toCaptureRefs)* )
226- // println(s"toCaptureSet: $tree -> $refs")
200+ val refs = CaptureSet (tree.retainedSet.retainedElements* )
227201 tree.putAttachment(Captures , refs)
228202 refs
229203
0 commit comments