Skip to content

Commit affe337

Browse files
committed
[IRGen] correct the order of demangling compat checks
In general, we need to check the features of a type in order of newest to oldest, when determining the runtime version that supports demangling that type.
1 parent 021dc4c commit affe337

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

lib/IRGen/GenReflection.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,18 @@ class PrintMetadataSource
174174

175175
Optional<llvm::VersionTuple>
176176
getRuntimeVersionThatSupportsDemanglingType(CanType type) {
177+
// The Swift 5.5 runtime is the first version able to demangle types
178+
// related to concurrency.
179+
bool needsConcurrency = type.findIf([](CanType t) -> bool {
180+
if (auto fn = dyn_cast<AnyFunctionType>(t)) {
181+
return fn->isAsync() || fn->isSendable() || fn->hasGlobalActor();
182+
}
183+
return false;
184+
});
185+
if (needsConcurrency) {
186+
return llvm::VersionTuple(5, 5);
187+
}
188+
177189
// Associated types of opaque types weren't mangled in a usable form by the
178190
// Swift 5.1 runtime, so we needed to add a new mangling in 5.2.
179191
if (type->hasOpaqueArchetype()) {
@@ -192,16 +204,6 @@ getRuntimeVersionThatSupportsDemanglingType(CanType type) {
192204
// involving them.
193205
}
194206

195-
bool needsConcurrency = type.findIf([](CanType t) -> bool {
196-
if (auto fn = dyn_cast<AnyFunctionType>(t)) {
197-
return fn->isAsync() || fn->isSendable() || fn->hasGlobalActor();
198-
}
199-
return false;
200-
});
201-
if (needsConcurrency) {
202-
return llvm::VersionTuple(5, 5);
203-
}
204-
205207
return None;
206208
}
207209

0 commit comments

Comments
 (0)