swift
aed05b9a - Obj-C class metatypes should never satisfy Obj-C existentials

Commit
1 year ago
Obj-C class metatypes should never satisfy Obj-C existentials Given this ``` @objc protocol P { func f() } class C: P { func f() {} } ``` the casts `C.self is any P` and `C.self as? any P` should always fail, because the metatype of `C.self` does not have an `f()` implementation. These casts previously succeeded because the runtime implementation deferred to Obj-C's `[o conformsToProtocol:p]`, and that behaves differently depending on whether `o` is a class instance or a Class itself. Since these casts should never succeed, I've just modified the Swift runtime logic to fail whenever the source of the cast is an Obj-C Class and the target is a protocol existential. Resolves: rdar://106973771
Author
Parents
Loading