-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Capability class is not properly boxed in implicit type argument #16725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think this issue can be closed now since both variables cause errors as expected. |
Yes you are right. The issue is not longer reproducible due to the change in the way we guard scoped capability (previously, it depends on the boxes but now there is a no-covariant- But the root cause of this issue (that in some cases capability classes are not recognised as impure and therefore not properly boxed) is not fixed. So it is still causing other soundness problems, like the following variant of this issue: import language.experimental.captureChecking
@annotation.capability
class IO:
def brewCoffee(): Unit = ???
def usingIO[T](op: IO => T): T = ???
type Wrapper[T] = [R] -> (f: T => R) -> R
def mk[T](x: T): Wrapper[T] = [R] => f => f(x)
def useWrappedIO(wrapper: Wrapper[IO]): () -> Unit =
() =>
wrapper: io =>
io.brewCoffee()
def main(): Unit =
val escaped = usingIO(io => useWrappedIO(mk(io)))
escaped() // boom With a combination of |
I checked the issue again and it turns out that actually the recent reproduction is completely a new one with a different cause. Another minimisation that is more salient: def runOps(ops: List[() => Unit]): () -> Unit =
() =>
ops.foreach: op =>
op() |
Compiler version
main
Minimized code
Output
Expectation
Both
ok
andboom
should issue an error, but nowboom
won't b/c of the explicit type argument. This is because inSetup
the type arugmentCanIO
inallowIO[CanIO]
will not be boxed when it is written out explicitly.The text was updated successfully, but these errors were encountered: