Closed
Description
Compiler version
main
Minimized code
import language.experimental.captureChecking
trait Box[Cap^]:
def store(f: (() -> Unit)^{Cap^}): Unit
def run[Cap^](f: Box[Cap]^{Cap^} => Unit): Box[Cap]^{Cap^} =
new Box[Cap]:
private var item: () ->{Cap^} Unit = () => ()
def store(f: () ->{Cap^} Unit): Unit = item = f
Output
-- Error: issues/box-store.scala:9:43 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
9 | def store(f: () ->{Cap^} Unit): Unit = item = f
| ^^^^
| Local reach capability Cap leaks into capture scope of method run
1 error found
Expectation
There should not be an error.
From @natsukagami when he was capture checking gears.