Checking protocol conformances with metatypes

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

Any ideas how I can fix this?

Terms of Service

Privacy Policy

Cookie Policy