I’m interested in knowing if there’s a direct solution to the following issue: Marker protocol 'Sendable' cannot be used in a conditional cast. Sendable is a marker protocol, and as such, it’s evaluated at compile time. However, the compiler should recognize if both sides of the cast are Sendable, so it should simply ignore the Sendable part. Is this just a limitation of the current compiler or am I overlooking something?
protocol A {}
protocol B: A {
func f()
}
class Z {
let c: (any A & Sendable)? = nil
func e () {
if let d = c as? (any B & Sendable) { // Marker protocol 'Sendable' cannot be used in a conditional cast
{ @Sendable in
d.f()
}()
}
}
}