Skip to content

Lack of support in CC: fresh caps inside type arguments #23421

@Linyxus

Description

@Linyxus

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 // error 

Looks 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`

Originally posted by @bracevac in #21675

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions