Closed
Description
Compiler version
main
branch
Minimized code
import language.experimental.captureChecking
import java.io.*
object Test:
class Logger(f: OutputStream^):
def log(msg: String): Unit = ???
def usingFile[sealed T](name: String, op: OutputStream^ => T): T =
val f = new FileOutputStream(name)
val result = op(f)
f.close()
result
def usingLogger[sealed T](f: OutputStream^)(op: Logger^{f} => T): T = ???
usingFile(
"foo",
file => {
usingLogger(file)(l => () => l.log("test")) // leaking the local logger
}
) // should be error but it compiles
Output
It compiles, but the last lines should be rejected since the scoped capability is leaked in the result.
Expectation
There should be an error on the last lines.