Skip to content

Commit 5217db0

Browse files
committed
runtime: clean up unused variable warning
classType is unused without ObjC interop. Simplify the code a bit by increasing the scope covered by the SWIFT_OBJC_INTEROP. It also silences the warning.
1 parent c320e6f commit 5217db0

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

stdlib/public/runtime/Casting.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,27 +67,25 @@ extern "C" const void *swift_dynamicCastObjCProtocolConditional(
6767
static void _buildNameForMetadata(const Metadata *type,
6868
bool qualified,
6969
std::string &result) {
70+
#if SWIFT_OBJC_INTEROP
7071
if (type->getKind() == MetadataKind::Class) {
7172
auto classType = static_cast<const ClassMetadata *>(type);
72-
#if SWIFT_OBJC_INTEROP
7373
// Look through artificial subclasses.
7474
while (classType->isTypeMetadata() && classType->isArtificialSubclass())
7575
classType = classType->SuperClass;
76-
76+
7777
// Ask the Objective-C runtime to name ObjC classes.
7878
if (!classType->isTypeMetadata()) {
7979
result += class_getName(classType);
8080
return;
8181
}
82-
#endif
8382
} else if (type->getKind() == MetadataKind::ObjCClassWrapper) {
84-
#if SWIFT_OBJC_INTEROP
8583
auto objcWrapper = static_cast<const ObjCClassWrapperMetadata *>(type);
8684
const char *className = class_getName((Class)objcWrapper->Class);
8785
result = className;
8886
return;
89-
#endif
9087
}
88+
#endif
9189

9290
// Use the remangler to generate a mangled name from the type metadata.
9391
auto demangling = _swift_buildDemanglingForMetadata(type);

0 commit comments

Comments
 (0)