Avatar
Avatar
Iceman
@swift-6.2.3 -swift-version 6 func f(object: Any) -> any CustomStringConvertible & Sendable { if let object = object as? any (CustomStringConvertible & Sendable) { return object } if let object = object as? any (CustomStringConvertible) { return object } return "" } (edited)
exit status 1 with stderr:<stdin>:2:28: error: marker protocol 'Sendable' cannot be used in a conditional cast 1 | func f(object: Any) -> any CustomStringConvertible & Sendable { 2 | if let object = object as? any (CustomStringConvertible & Sendable) { | `- error: marker protocol 'Sendable' cannot be used in a conditional cast 3 | return object 4 | } <stdin>:6:16: error: type 'any CustomStringConvertible' does not conform to the 'Sendable' protocol 4 | } 5 | if let object = object as? any (CustomStringConvertible) { 6 | return object | `- error: type 'any CustomStringConvertible' does not conform to the 'Sendable' protocol 7 | } 8 | return "" (edited)