From 84a0b43ab3015d32ef2b8f64a0344d9844906e37 Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Thu, 24 Jul 2025 12:30:50 -0400 Subject: [PATCH] Don't use `_getSuperclass()` from the Swift runtime. To determine if a class is a subclass of another, we can use `T.self is U.Type` in an implicitly-opened existential context. Prior to the Swift 6 language mode, type existentials weren't openable, so we had to recursively call a runtime function to check this. That's no longer a concern for us. --- Sources/Testing/Parameterization/TypeInfo.swift | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Sources/Testing/Parameterization/TypeInfo.swift b/Sources/Testing/Parameterization/TypeInfo.swift index 0bceff744..de377e6be 100644 --- a/Sources/Testing/Parameterization/TypeInfo.swift +++ b/Sources/Testing/Parameterization/TypeInfo.swift @@ -360,13 +360,10 @@ extension TypeInfo { /// - Returns: Whether `subclass` is a subclass of, or is equal to, /// `superclass`. func isClass(_ subclass: AnyClass, subclassOf superclass: AnyClass) -> Bool { - if subclass == superclass { - true - } else if let subclassImmediateSuperclass = _getSuperclass(subclass) { - isClass(subclassImmediateSuperclass, subclassOf: superclass) - } else { - false + func open(_: T.Type, _: U.Type) -> Bool where T: AnyObject, U: AnyObject { + T.self is U.Type } + return open(subclass, superclass) } // MARK: - CustomStringConvertible, CustomDebugStringConvertible, CustomTestStringConvertible