I'm trying to write a function that takes types as inputs and tests for conformances. Here's a simplified example:
let x = 3
protocol Test {}
extension Int: Test {}
x is Test // true
Int.self is Test.Type // true
func testing1<T>(type: T.Type) -> Bool {
return type is Test.Type
}
func testing2<T, P>(type: T.Type, protocol: P.Type) -> Bool {
return type is P.Type
}
testing1(type: Int.self) // true
testing2(type: Int.self, protocol: Test.self) // false
Hate bumping an old thread, but I would also want to know if there is a swift construct that would result in swift_conformsToProtocol being called inside testing2.