Avatar
@swift-5.2.5 protocol P { static func foo() } extension P { static func foo() { print("P") } } extension Int: P { static func foo() { print("Int") } } func callFoo<T>(_ v: T) { print("Calling foo for \(type(of: v))") print("T is P ? \(T.self is P.Type)") if let t = type(of: v) as? P.Type { t.foo() } else { print("Failed to cast") } } let a: P = 1 callFoo(a) callFoo(1)