From 04bf5cedf48091c8d124670cfbd3ecc0a0c72a52 Mon Sep 17 00:00:00 2001 From: Apple Date: Thu, 2 Apr 2020 17:19:03 +0000 Subject: [PATCH] objc4-781.2.tar.gz --- runtime/objc-runtime-new.mm | 4 +++- test/runtime.m | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/runtime/objc-runtime-new.mm b/runtime/objc-runtime-new.mm index ee12127..e158375 100644 --- a/runtime/objc-runtime-new.mm +++ b/runtime/objc-runtime-new.mm @@ -5604,7 +5604,9 @@ objc_class::demangledName(bool needsLock) // Return previously demangled name if available. if (isRealized() || isFuture()) { - if (!isAnySwift()) { + // Swift metaclasses don't have the is-Swift bit. + // We can't take this shortcut for them. + if (!isMetaClass() && !isAnySwift()) { return data()->ro()->name; } auto rwe = data()->ext(); diff --git a/test/runtime.m b/test/runtime.m index ec8fda8..50bd68c 100644 --- a/test/runtime.m +++ b/test/runtime.m @@ -212,6 +212,14 @@ int main() testassert(list2[count] == NULL); free(list2); free(objc_copyClassList(NULL)); + + // Make sure metaclasses get demangled too. + testassert(strcmp(class_getName([TestRoot class]), class_getName(object_getClass([TestRoot class]))) == 0); + testassert(strcmp(class_getName([Sub class]), class_getName(object_getClass([Sub class]))) == 0); + testassert(strcmp(class_getName([SwiftV1Class class]), class_getName(object_getClass([SwiftV1Class class]))) == 0); + testassert(strcmp(class_getName([SwiftV1Class2 class]), class_getName(object_getClass([SwiftV1Class2 class]))) == 0); + testassert(strcmp(class_getName([SwiftV1Class3 class]), class_getName(object_getClass([SwiftV1Class3 class]))) == 0); + testassert(strcmp(class_getName([SwiftV1Class4 class]), class_getName(object_getClass([SwiftV1Class4 class]))) == 0); succeed(__FILE__); } -- 2.45.2