Skip to content

Commit e8d0e8f

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. (cherry picked from commit 24c761b)
1 parent 46fe854 commit e8d0e8f

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,36 @@
1515
// REQUIRES: CPU=x86_64
1616
// REQUIRES: OS=macosx
1717
// REQUIRES: executable_test
18+
actor MyActor { }
1819

1920
protocol MyProtocol {
2021
associatedtype AssocSendable
2122
associatedtype AssocAsync
2223
associatedtype AssocGlobalActor
24+
associatedtype AssocIsolated
2325
}
2426

2527
typealias SendableFn = @Sendable () -> Void
2628
typealias AsyncFn = () async -> Void
2729
typealias GlobalActorFn = @MainActor () -> Void
30+
typealias ActorIsolatedFn = (isolated MyActor) -> String
2831

2932
struct MyStruct: MyProtocol {
3033
typealias AssocSendable = SendableFn
3134
typealias AssocAsync = AsyncFn
3235
typealias AssocGlobalActor = GlobalActorFn
36+
typealias AssocIsolated = ActorIsolatedFn
3337
}
3438

3539
func assocSendable<T: MyProtocol>(_: T.Type) -> Any.Type { return T.AssocSendable.self }
3640
func assocAsync<T: MyProtocol>(_: T.Type) -> Any.Type { return T.AssocAsync.self }
3741
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 }
3843

3944
assert(assocSendable(MyStruct.self) == SendableFn.self)
4045
assert(assocAsync(MyStruct.self) == AsyncFn.self)
4146
assert(assocGlobalActor(MyStruct.self) == GlobalActorFn.self)
47+
assert(assocIsolated(MyStruct.self) == ActorIsolatedFn.self)
4248

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

7076
// NEW-NOT: call swiftcc %swift.metadata_response @"$syyScMYccMa"
7177
// 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)