I have the following code:
//> using scala 3.8.1
//> using option -language:experimental.captureChecking
def oneOf[A](as: List[DummyImplicit ?=> A]): A =
as(0)
It fails with the following error:
[error] Local reach capability as* leaks into capture scope of method oneOf.
[error] You could try to abstract the capabilities referred to by as* in a capset variable.
[error] as(0)
[error] ^^^^^
Which I find a little surprising: in my head, oneOf uses whatever is captured by the DummyImplicit ?=> A, but it doesn’t capture them. Am I missing something? The error message mentions reach capabilities, so I’m going to assume yes, I have indeed missed something…
I’ve been able to reproduce this with 3.8.0, 3.8.1 and 3.8.3-RC1-bin-20260122-99fe89c-NIGHTLY.
EDIT: I should have done this immediately, sorry - I followed the instructions of the error message, and this compiles:
//> using scala 3.8.1
//> using option -language:experimental.captureChecking
def oneOf[A, B^](as: List[DummyImplicit ?->{B} A]): A =
as(0)
I’ll be honest, this confuses me even more.