@@ -52,15 +52,14 @@ def ccState(using Context): CCState =
5252extension (tree : Tree )
5353
5454 /** The type representing the capture set of @retains, @retainsCap or @retainsByName
55- * annotation tree.
55+ * annotation tree (represented as an Apply node) .
5656 */
57- def retainedSet (using Context ): Type =
58- val rcap = defn.RetainsCapAnnot
59- if tree.symbol == rcap || tree.symbol.maybeOwner == rcap then
60- defn.captureRoot.termRef
61- else tree match
62- case Apply (TypeApply (_, refs :: Nil ), _) => refs.tpe
63- case _ => NoType
57+ def retainedSet (using Context ): Type = tree match
58+ case Apply (TypeApply (_, refs :: Nil ), _) => refs.tpe
59+ case _ =>
60+ if tree.symbol.maybeOwner == defn.RetainsCapAnnot
61+ then defn.captureRoot.termRef
62+ else NoType
6463
6564extension (tp : Type )
6665
@@ -85,7 +84,7 @@ extension (tp: Type)
8584 def retainedElementsRaw (using Context ): List [Type ] = tp match
8685 case OrType (tp1, tp2) =>
8786 tp1.retainedElementsRaw ++ tp2.retainedElementsRaw
88- case AnnotatedType (tp1, ann : RetainingAnnotation ) if tp1.derivesFrom(defn.Caps_CapSet ) && ann.isStrict =>
87+ case AnnotatedType (tp1, ann : RetainingAnnotation ) if tp1.derivesFrom(defn.Caps_CapSet ) =>
8988 ann.retainedType.retainedElementsRaw
9089 case tp =>
9190 tp.dealiasKeepAnnots match
@@ -229,7 +228,8 @@ extension (tp: Type)
229228 if tp.isBoxed || parent.derivesFrom(defn.Caps_CapSet ) then tp
230229 else tp.boxed
231230 case tp @ AnnotatedType (parent, ann : RetainingAnnotation )
232- if ann.isStrict && ! parent.derivesFrom(defn.Caps_CapSet ) =>
231+ if ! parent.derivesFrom(defn.Caps_CapSet ) =>
232+ assert(ann.isStrict)
233233 CapturingType (parent, ann.toCaptureSet, boxed = true )
234234 case tp @ AnnotatedType (parent, ann) =>
235235 tp.derivedAnnotatedType(parent.boxDeeply, ann)
0 commit comments