Skip to content

Commit 24c761b

Browse files
committed
Cannot back-deploy mangled names including isolated parameters.
Isolated parameters were introduced with concurrency, so don't mangle names including them in back-deployed code.
1 parent 2747285 commit 24c761b

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

lib/IRGen/GenReflection.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,15 @@ getRuntimeVersionThatSupportsDemanglingType(CanType type) {
178178
// related to concurrency.
179179
bool needsConcurrency = type.findIf([](CanType t) -> bool {
180180
if (auto fn = dyn_cast<AnyFunctionType>(t)) {
181-
return fn->isAsync() || fn->isSendable() || fn->hasGlobalActor();
181+
if (fn->isAsync() || fn->isSendable() || fn->hasGlobalActor())
182+
return true;
183+
184+
for (const auto param: fn->getParams()) {
185+
if (param.isIsolated())
186+
return true;
187+
}
188+
189+
return false;
182190
}
183191
return false;
184192
});

test/Concurrency/Backdeploy/mangling.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,36 @@
1515
// REQUIRES: CPU=x86_64
1616
// REQUIRES: OS=macosx
1717
// REQUIRES: executable_test
18-
19-
// rdar://83465277 - failing when using OS stdlib on 10.15 and earlier.
20-
// UNSUPPORTED: use_os_stdlib
18+
actor MyActor { }
2119

2220
protocol MyProtocol {
2321
associatedtype AssocSendable
2422
associatedtype AssocAsync
2523
associatedtype AssocGlobalActor
24+
associatedtype AssocIsolated
2625
}
2726

2827
typealias SendableFn = @Sendable () -> Void
2928
typealias AsyncFn = () async -> Void
3029
typealias GlobalActorFn = @MainActor () -> Void
30+
typealias ActorIsolatedFn = (isolated MyActor) -> String
3131

3232
struct MyStruct: MyProtocol {
3333
typealias AssocSendable = SendableFn
3434
typealias AssocAsync = AsyncFn
3535
typealias AssocGlobalActor = GlobalActorFn
36+
typealias AssocIsolated = ActorIsolatedFn
3637
}
3738

3839
func assocSendable<T: MyProtocol>(_: T.Type) -> Any.Type { return T.AssocSendable.self }
3940
func assocAsync<T: MyProtocol>(_: T.Type) -> Any.Type { return T.AssocAsync.self }
4041
func assocGlobalActor<T: MyProtocol>(_: T.Type) -> Any.Type { return T.AssocGlobalActor.self }
42+
func assocIsolated<T: MyProtocol>(_: T.Type) -> Any.Type { return T.AssocIsolated.self }
4143

4244
assert(assocSendable(MyStruct.self) == SendableFn.self)
4345
assert(assocAsync(MyStruct.self) == AsyncFn.self)
4446
assert(assocGlobalActor(MyStruct.self) == GlobalActorFn.self)
47+
assert(assocIsolated(MyStruct.self) == ActorIsolatedFn.self)
4548

4649
// type metadata accessor for @Sendable () -> ()
4750
// OLD: define linkonce_odr hidden swiftcc %swift.metadata_response @"$syyYbcMa"
@@ -72,3 +75,9 @@ assert(assocGlobalActor(MyStruct.self) == GlobalActorFn.self)
7275

7376
// NEW-NOT: call swiftcc %swift.metadata_response @"$syyScMYccMa"
7477
// NEW: call %swift.type* @__swift_instantiateConcreteTypeFromMangledName({ i32, i32 }* @"$syyScMYccMD")
78+
79+
// OLD: call swiftcc %swift.metadata_response @"$sSS4main7MyActorCYicMa"(i64 0) #3
80+
// OLD-NOT: call %swift.type* @__swift_instantiateConcreteTypeFromMangledName({ i32, i32 }* @"$sSS4main7MyActorCYicMD")
81+
82+
// NEW-NOT: call swiftcc %swift.metadata_response @"$sSS4main7MyActorCYicMa"(i64 0) #3
83+
// NEW: call %swift.type* @__swift_instantiateConcreteTypeFromMangledName({ i32, i32 }* @"$sSS4main7MyActorCYicMD")

0 commit comments

Comments
 (0)