I couldn't find any information on this in the structured concurrency proposal, but has there been any discussion of making the cases of a Sendable enum act as a @Sendable function? Currently the following produces a warning:
enum Foo: Sendable {
case bar(Int)
}
let f: @Sendable (Int) -> Foo = Foo.bar
…saying that Foo.bar is not @Sendable. As far as I can tell it seems @Sendable to me.
Is this theoretically possible at some point, or was it specifically disallowed for a particular reason?
I've run into something similar to this before, but in that situation it was a func rather than an enum case. This solution worked for me then; does it work here, too?
let f: @Sendable (Int) -> Foo = { .bar($0) }
Regardless, I think it is odd that this doesn't work.
Yeah that's right and I should have mentioned. Using { Foo.bar($0) } does get around the problem. However, it can make call sites of APIs look really bad, so I was hoping Foo.bar would work.