Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bracevac committed Jan 22, 2025
1 parent 24ddd74 commit c3fcd7c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion compiler/src/dotty/tools/dotc/cc/CaptureRef.scala
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,15 @@ trait CaptureRef extends TypeProxy, ValueType:
case info: SingletonCaptureRef => test(info)
case info: AndType => viaInfo(info.tp1)(test) || viaInfo(info.tp2)(test)
case info: OrType => viaInfo(info.tp1)(test) && viaInfo(info.tp2)(test)
case info @ CapturingType(_,_) if this.derivesFrom(defn.Caps_CapSet) => test(info)
case info @ CapturingType(_,_) if this.derivesFrom(defn.Caps_CapSet) =>
/*
If `this` is a capture set variable `C^`, then it is possible that it can be
reached from term variables in a reachability chain through the context.
For instance, in `def test[C^](src: Foo^{C^}) = { val x: Foo^{src} = src; val y: Foo^{x} = x; y }`
we expect that `C^` subsumes `x` and `y` in the body of the method
(cf. test case cc-poly-varargs.scala for a more involved example).
*/
test(info)
case _ => false

(this eq y)
Expand Down Expand Up @@ -150,6 +158,10 @@ trait CaptureRef extends TypeProxy, ValueType:
case TypeBounds(_, hi: CaptureRef) => this.subsumes(hi)
case _ => y.captureSetOfInfo.elems.forall(this.subsumes)
case CapturingType(parent, refs) if parent.derivesFrom(defn.Caps_CapSet) || this.derivesFrom(defn.Caps_CapSet) =>
/* The second condition in the guard is for `this` being a `CapSet^{a,b...}` and etablishing a
potential reachability chain through `y`'s capture to a binding with
`this`'s capture set (cf. `CapturingType` case in `def viaInfo` above for more context).
*/
refs.elems.forall(this.subsumes)
case _ => false
|| this.match
Expand Down

0 comments on commit c3fcd7c

Please # to comment.