Skip to content

Commit badba55

Browse files
committed
[IRGen] Mangling of nonisolated(nonsending) function types was introduced in Swift 6.2
We can't use mangled named when back-deploying earlier.
1 parent a73650c commit badba55

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

lib/IRGen/GenReflection.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,10 @@ getRuntimeVersionThatSupportsDemanglingType(CanType type) {
204204
Swift_5_5,
205205
Swift_6_0,
206206
Swift_6_1,
207+
Swift_6_2,
207208

208209
// Short-circuit if we find this requirement.
209-
Latest = Swift_6_1
210+
Latest = Swift_6_2
210211
};
211212

212213
VersionRequirement latestRequirement = None;
@@ -223,6 +224,11 @@ getRuntimeVersionThatSupportsDemanglingType(CanType type) {
223224
auto isolation = fn->getIsolation();
224225
auto sendingResult = fn->hasSendingResult();
225226

227+
// The mangling for nonisolated(nonsending) function types was introduced
228+
// in Swift 6.2.
229+
if (isolation.isNonIsolatedCaller())
230+
return addRequirement(Swift_6_2);
231+
226232
// The Swift 6.1 runtime fixes a bug preventing successful demangling
227233
// when @isolated(any) or global actor isolation is combined with a
228234
// sending result.
@@ -290,6 +296,7 @@ getRuntimeVersionThatSupportsDemanglingType(CanType type) {
290296
});
291297

292298
switch (latestRequirement) {
299+
case Swift_6_2: return llvm::VersionTuple(6, 2);
293300
case Swift_6_1: return llvm::VersionTuple(6, 1);
294301
case Swift_6_0: return llvm::VersionTuple(6, 0);
295302
case Swift_5_5: return llvm::VersionTuple(5, 5);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: %target-swift-frontend -target %target-cpu-apple-macos12 -emit-ir -o - -primary-file %s | %FileCheck %s
2+
// REQUIRES: concurrency
3+
// REQUIRES: OS=macosx
4+
5+
func useGenericMetatype(_ type: Any.Type) { }
6+
7+
// CHECK-LABEL: define hidden swiftcc void @"$s52backward_deploy_nonisolated_nonsending_function_type29testNonisolatedNonsendingTypeyyF"()
8+
func testNonisolatedNonsendingType() {
9+
typealias Fn = nonisolated(nonsending) () async throws -> Int
10+
11+
// CHECK: call swiftcc %swift.metadata_response @"$sSiyYaKYCcMa"
12+
// CHECK: call swiftcc void @"$s52backward_deploy_nonisolated_nonsending_function_type18useGenericMetatypeyyypXpF"
13+
useGenericMetatype(Fn.self)
14+
}
15+
16+
// CHECK-LABEL: define linkonce_odr hidden swiftcc %swift.metadata_response @"$sSiyYaKYCcMa"
17+
// CHECK: call ptr @swift_getExtendedFunctionTypeMetadata(i{{32|64}} 2768240640, {{i32|i64}} 0, ptr null, ptr null, ptr @"$sSiN"

0 commit comments

Comments
 (0)