Skip to content

Commit 72eb0d3

Browse files
authored
Merge pull request #36476 from DougGregor/global-actor-mangling-hack
2 parents 3b2c3d2 + 351cee3 commit 72eb0d3

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

lib/AST/ASTMangler.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2857,10 +2857,21 @@ CanType ASTMangler::getDeclTypeForMangling(
28572857
return C.TheErrorType;
28582858
}
28592859

2860+
Type ty = decl->getInterfaceType()->getReferenceStorageReferent();
2861+
2862+
// Strip the global actor out of the mangling.
2863+
ty = ty.transform([](Type type) {
2864+
if (auto fnType = type->getAs<AnyFunctionType>()) {
2865+
if (fnType->getGlobalActor()) {
2866+
return Type(fnType->withExtInfo(
2867+
fnType->getExtInfo().withGlobalActor(Type())));
2868+
}
2869+
}
2870+
2871+
return type;
2872+
});
28602873

2861-
auto canTy = decl->getInterfaceType()
2862-
->getReferenceStorageReferent()
2863-
->getCanonicalType();
2874+
auto canTy = ty->getCanonicalType();
28642875

28652876
if (auto gft = dyn_cast<GenericFunctionType>(canTy)) {
28662877
genericSig = gft.getGenericSignature();
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %target-swift-frontend -emit-silgen %s -module-name test -swift-version 5 -enable-experimental-concurrency | %FileCheck %s
2+
// REQUIRES: concurrency
3+
4+
// Declarations don't mangle global actor types.
5+
// CHECK: @$s4test10returnsOptyxycSgAClF
6+
func returnsOpt<R>(_ fn: (@MainActor () -> R)?) -> (() -> R)? {
7+
typealias Fn = (() -> R)?
8+
return unsafeBitCast(fn, to: Fn.self)
9+
}

0 commit comments

Comments
 (0)