Cast Any to Sendable

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.

@Dmitriy_Ignatyev Did you ever figure this out?

Not yet. Temporary solution is to mark some error implementations with @uncheckedSendable and leave them with [String: Any]

One strange thing is that [String: Any] dict itself is Sendbale, but its values can not be casted to Sendable, which is confusing.

Another option I've found for detecting a Sendable type at runtime is to use an overloaded interface and @_disfavoredOverload, where one constrains the generic and the other does not.