Skip to content

Commit d016cce

Browse files
committed
WIP fixing subsumes
1 parent df06d60 commit d016cce

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

Diff for: compiler/src/dotty/tools/dotc/cc/CaptureRef.scala

+15-8
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,9 @@ trait CaptureRef extends TypeProxy, ValueType:
100100
* x: x1.type /\ x1 subsumes y ==> x subsumes y
101101
* TODO: Document path cases
102102
*/
103-
final def subsumes(y: CaptureRef)(using Context): Boolean =
104-
103+
// import reporting.trace
104+
final def subsumes(y: CaptureRef)(using Context): Boolean = // trace.force(i"subsumes $this, $y"):
105+
105106
def subsumingRefs(x: Type, y: Type): Boolean = x match
106107
case x: CaptureRef => y match
107108
case y: CaptureRef => x.subsumes(y)
@@ -137,20 +138,26 @@ trait CaptureRef extends TypeProxy, ValueType:
137138
case MaybeCapability(y1) => this.stripMaybe.subsumes(y1)
138139
case y: TypeRef if y.symbol.info.derivesFrom(defn.Caps_CapSet) =>
139140
y.info match
140-
case _: TypeAlias => y.captureSetOfInfo.elems.exists(this.subsumes)
141+
case _: TypeAlias => y.captureSetOfInfo.elems.forall(this.subsumes)
141142
case TypeBounds(_, hi: CaptureRef) => this.subsumes(hi)
142-
case _ => false
143+
case _ => y.captureSetOfInfo.elems.forall(this.subsumes)
143144
case _ => false
144145
|| this.match
145146
case ReachCapability(x1) => x1.subsumes(y.stripReach)
146147
case x: TermRef => viaInfo(x.info)(subsumingRefs(_, y))
147148
case x: TermParamRef => subsumesExistentially(x, y)
148-
case x: TypeRef if x.symbol.info.derivesFrom(defn.Caps_CapSet) =>
149+
case x: TypeRef if x.derivesFrom(defn.Caps_CapSet) =>
149150
x.info match
150-
case _: TypeAlias => x.captureSetOfInfo.elems.exists(_.subsumes(y))
151-
case TypeBounds(lo: CaptureRef, _) => lo.subsumes(y)
152-
case _ => false
151+
case _: TypeAlias =>
152+
x.captureSetOfInfo.elems.exists(_.subsumes(y))
153+
case TypeBounds(lo: CaptureRef, _) =>
154+
lo.subsumes(y)
155+
case _ =>
156+
x.captureSetOfInfo.elems.exists(_.subsumes(y))
153157
case x: TypeRef => assumedContainsOf(x).contains(y)
158+
case AnnotatedType(parent, ann)
159+
if ann.symbol.isRetains && parent.derivesFrom(defn.Caps_CapSet) =>
160+
ann.tree.toCaptureSet.elems.exists(_.subsumes(y))
154161
case _ => false
155162
end subsumes
156163

0 commit comments

Comments
 (0)