Skip to content

Commit

Permalink
WIP fixing subsumes
Browse files Browse the repository at this point in the history
  • Loading branch information
noti0na1 committed Nov 22, 2024
1 parent df06d60 commit d016cce
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions compiler/src/dotty/tools/dotc/cc/CaptureRef.scala
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ trait CaptureRef extends TypeProxy, ValueType:
* x: x1.type /\ x1 subsumes y ==> x subsumes y
* TODO: Document path cases
*/
final def subsumes(y: CaptureRef)(using Context): Boolean =

// import reporting.trace
final def subsumes(y: CaptureRef)(using Context): Boolean = // trace.force(i"subsumes $this, $y"):

def subsumingRefs(x: Type, y: Type): Boolean = x match
case x: CaptureRef => y match
case y: CaptureRef => x.subsumes(y)
Expand Down Expand Up @@ -137,20 +138,26 @@ trait CaptureRef extends TypeProxy, ValueType:
case MaybeCapability(y1) => this.stripMaybe.subsumes(y1)
case y: TypeRef if y.symbol.info.derivesFrom(defn.Caps_CapSet) =>
y.info match
case _: TypeAlias => y.captureSetOfInfo.elems.exists(this.subsumes)
case _: TypeAlias => y.captureSetOfInfo.elems.forall(this.subsumes)
case TypeBounds(_, hi: CaptureRef) => this.subsumes(hi)
case _ => false
case _ => y.captureSetOfInfo.elems.forall(this.subsumes)
case _ => false
|| this.match
case ReachCapability(x1) => x1.subsumes(y.stripReach)
case x: TermRef => viaInfo(x.info)(subsumingRefs(_, y))
case x: TermParamRef => subsumesExistentially(x, y)
case x: TypeRef if x.symbol.info.derivesFrom(defn.Caps_CapSet) =>
case x: TypeRef if x.derivesFrom(defn.Caps_CapSet) =>
x.info match
case _: TypeAlias => x.captureSetOfInfo.elems.exists(_.subsumes(y))
case TypeBounds(lo: CaptureRef, _) => lo.subsumes(y)
case _ => false
case _: TypeAlias =>
x.captureSetOfInfo.elems.exists(_.subsumes(y))
case TypeBounds(lo: CaptureRef, _) =>
lo.subsumes(y)
case _ =>
x.captureSetOfInfo.elems.exists(_.subsumes(y))
case x: TypeRef => assumedContainsOf(x).contains(y)
case AnnotatedType(parent, ann)
if ann.symbol.isRetains && parent.derivesFrom(defn.Caps_CapSet) =>
ann.tree.toCaptureSet.elems.exists(_.subsumes(y))
case _ => false
end subsumes

Expand Down

0 comments on commit d016cce

Please sign in to comment.