For protocol types, substituting into a generic parameter T in T.Type can only give you the concrete metatype for the protocol, Error.Protocol, and not what you want, the existential metatype Error.Type. Inside conforms(to:), you're really asking MyError.self is Error.Protocol, which is false because only Error.self is an instance of Error.Protocol. You will need to bind T to the entire existential metatype Error.Type in order to do the test you want; something like this:
func conforms<T>(to type: T.Type) -> Bool {
print(T.self)
return MyError.self is T
}
let errorType: Any.Type = Error.Type.self
struct MyError: Error {}
print(_openExistential(errorType, do: conforms(to:)))
In the context I'm working in, though, I already have a value of Error.Protocol. Is there any way to dynamically get an Error.Type.Protocol out of that? (type(of: errorType) yields an Error.Protocol.Type, which makes sense but isn't helpful.
I was working with metadata layout earlier (using Echo as a reference), but it's doing some funny things in C to populate protocol conformance data, which is complexity I was hoping to avoid.
There is no real protocol polymorphism in Swift right now, so there isn't a way to get from P to P.Type within the confines of the language itself. You would have to use the runtime yourself to do the dynamic protocol tests.