Open
Description
Another question about this example is how do we actually instantiate such collections:
import language.experimental.captureChecking import caps.* trait Collection[T] extends Mutable: update def add(elem: T): Unit update def remove(elem: T): Unit def get(index: Int): Option[T] object Collection: def empty[T]: Collection[T] = ??? trait Foo: val thunks: Collection[() => Unit] // that's fine object FooImpl1 extends Foo: val thunks: Collection[() => Unit] = Collection.empty // errorLooks like a bug?
-- [E007] Type Mismatch Error: local/i21675.scala:17:39 ------------------------ 16 | val thunks: Collection[() => Unit] = Collection.empty | ^^^^^^^^^^^^^^^^ |Found: Collection[() ->? Unit]^{cap.rd} |Required: Collection[() => Unit]^{cap².rd} | |where: cap is a fresh root capability in the result type of method empty | cap² is a fresh root capability in the type of value thunks | | longer explanation available when compiling with `-explain`