[Runtime] Fix crash in protocol conformance checks on KVO artificial subclasses.

tryGetCompleteMetadataNonblocking crashes on artificial subclasses due to the NULL type descriptor. Explicitly check for artificial subclasses in getSuperclassForMaybeIncompleteMetadata and immediately return their Superclass field. Artificial subclasses are always fully initialized so we don't need to do anything special for them.

rdar://72583931
This commit is contained in:
Mike Ash
2021-06-17 14:45:58 -04:00
parent 75fb3c7f18
commit c3aa44368a
2 changed files with 18 additions and 0 deletions

View File

@@ -983,6 +983,16 @@ CastsTests.test("Do not overuse __SwiftValue") {
}
#endif
#if _runtime(_ObjC)
CastsTests.test("Artificial subclass protocol conformance") {
class SwiftClass: NSObject {}
let subclass: AnyClass = objc_allocateClassPair(SwiftClass.self,
"ArtificialSwiftSubclass", 0)!
objc_registerClassPair(subclass)
expectFalse(subclass is P.Type)
}
#endif
CastsTests.test("Do not overuse __SwiftValue (non-ObjC)") {
struct Bar {}
// This should succeed because this is what __SwiftValue boxing is for