Hello.
I'm trying to convert [String: Any] dict to [String: Sendable] dict. Trying do this, I get a compiler error: Marker protocol 'Sendable' cannot be used in a conditional cast.
Another example:
func test(_ val: Any) {
if val is Sendable { Error: Marker protocol 'Sendable' cannot be used in a conditional cast
}
}
What is the reason? Is there a way to check if underlying value of Any is Sendable?
The task I'm trying to solve is update our code base for Swift 5.6 and Xcode 13.3. We have a custom error protocol with userInfo payload of type [String: Any]. The Swift.Error protocol now inherits form Sendable. So all our error types need to be sendable, but [String: Any] is not Sendable by itself.
So, I want to replace [String: Any] with [String: Sendable & CustomStringConvertible].
The problem is when I create our CustomError from NSError, I need to convert NSError.userInfo to [String: Sendable & CustomStringConvertible]. If Any value from user info can't be casted to sendable, I want to replace it with string interpolation of Any value.