-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
area:experimental:ccCapture checking relatedCapture checking relatedarea:experimental:separation-checkingIssues regarding language.experimental.separationCheckingIssues regarding language.experimental.separationCheckingitype:bugstat:needs triageEvery issue needs to have an "area" and "itype" labelEvery issue needs to have an "area" and "itype" label
Description
Compiler version
Latest main (71bfc7c)
Minimized code
import language.experimental.captureChecking
import language.experimental.modularity
import caps.*
trait Collection[+T] extends Stateful:
self: Collection[T]^ =>
type Index
// slice should have its Index type member a subtype of the Collection's Index
def getSlice(): (Collection[T] { type Index <: self.Index })^{this.rd} = new Slice(this)
class Slice[+T](tracked val coll: Collection[T]) extends Collection[T]:
type Index = coll.IndexOutput
-- [E007] Type Mismatch Error: a.scala:10:77 -----------------------------------
10 | def getSlice(): (Collection[T] { type Index <: self.Index })^{this.rd} = new Slice(this)
| ^^^^^^^^^^^^^^^
|Found: Slice[T^'s1]{
| val coll: Collection[T]^{Collection.this.rd};
| val coll: Collection[T]^{Collection.this.rd}
|}^{Collection.this.rd}
|Required: Collection[T]{type Index <: Collection.this.Index}^{Collection.this.rd}
|
|Note that {Collection.this} is an exclusive capture set of the stateful type (Collection.this : Collection[T]^),
|it cannot subsume a read-only capture set of the stateful type Collection[T]^{Collection.this.rd}.
|
|Note that capability `Collection.this.rd` cannot flow into capture set {}.
|
|where: ^ refers to the root capability caps.any
|
| longer explanation available when compiling with `-explain`Expectation
The code compiles if capture checking is turned off and capture sets removed.
The code compiles if getSlice() is update and captures this, and slice takes a Collection[T]^:
trait Collection[+T] extends Stateful:
self: Collection[T]^ =>
type Index
// slice should have its Index type member a subtype of the Collection's Index
update def getSlice(): (Collection[T] { type Index <: self.Index })^{this} = new Slice(this)
class Slice[+T](tracked val coll: Collection[T]^) extends Collection[T]:
type Index = coll.IndexReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area:experimental:ccCapture checking relatedCapture checking relatedarea:experimental:separation-checkingIssues regarding language.experimental.separationCheckingIssues regarding language.experimental.separationCheckingitype:bugstat:needs triageEvery issue needs to have an "area" and "itype" labelEvery issue needs to have an "area" and "itype" label