Skip to content

Commit fa3f6dc

Browse files
committed
Fix and test the mangling of @isolated(any) function types
1 parent 0c05f82 commit fa3f6dc

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

include/swift/AST/ExtInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class FunctionTypeIsolation {
127127
enum class SILFunctionTypeIsolation {
128128
/// We don't normally record isolation in SIL function types,
129129
/// so the empty case here is "unknown".
130-
Unknown,
130+
Unknown,
131131

132132
/// The isolation of the function has been statically erased.
133133
/// This corresponds to @isolated(any).

lib/AST/ASTMangler.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2840,9 +2840,20 @@ void ASTMangler::appendFunctionSignature(AnyFunctionType *fn,
28402840
break;
28412841
}
28422842

2843-
if (Type globalActor = fn->getGlobalActor()) {
2844-
appendType(globalActor, sig);
2843+
auto isolation = fn->getIsolation();
2844+
switch (isolation.getKind()) {
2845+
case FunctionTypeIsolation::Kind::NonIsolated:
2846+
break;
2847+
case FunctionTypeIsolation::Kind::Parameter:
2848+
// Parameter isolation is already mangled in the parameters.
2849+
break;
2850+
case FunctionTypeIsolation::Kind::GlobalActor:
2851+
appendType(isolation.getGlobalActorType(), sig);
28452852
appendOperator("Yc");
2853+
break;
2854+
case FunctionTypeIsolation::Kind::Erased:
2855+
appendOperator("YA");
2856+
break;
28462857
}
28472858

28482859
if (auto *afd = dyn_cast_or_null<AbstractFunctionDecl>(forDecl)) {

lib/Demangling/NodePrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ class NodePrinter {
885885
}
886886
if (node->getChild(startIndex)->getKind()
887887
== Node::Kind::IsolatedAnyFunctionType) {
888-
Printer << "@isolated(any) ";
888+
print(node->getChild(startIndex), depth + 1);
889889
++startIndex;
890890
}
891891
if (node->getChild(startIndex)->getKind() ==

test/Demangle/Inputs/manglings.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,9 @@ $s9MacroUser016testFreestandingA9ExpansionyyF4Foo3L_V23bitwidthNumberedStructsfM
453453
@__swiftmacro_9MacroUser16MemberNotCoveredV33_4361AD9339943F52AE6186DD51E04E91Ll0dE0fMf0_ ---> freestanding macro expansion #2 of NotCovered(in _4361AD9339943F52AE6186DD51E04E91) in MacroUser.MemberNotCovered
454454
$sxSo8_NSRangeVRlzCRl_Cr0_llySo12ModelRequestCyxq_GIsPetWAlYl_TC ---> coroutine continuation prototype for @escaping @convention(thin) @convention(witness_method) @yield_once <A, B where A: AnyObject, B: AnyObject> @substituted <A> (@inout A) -> (@yields @inout __C._NSRange) for <__C.ModelRequest<A, B>>
455455
$SyyySGSS_IIxxxxx____xsIyFSySIxx_@xIxx____xxI ---> $SyyySGSS_IIxxxxx____xsIyFSySIxx_@xIxx____xxI
456-
$s12typed_throws15rethrowConcreteyyAA7MyErrorOYKF --> typed_throws.rethrowConcrete() throws(typed_throws.MyError) -> ()
456+
$s12typed_throws15rethrowConcreteyyAA7MyErrorOYKF ---> typed_throws.rethrowConcrete() throws(typed_throws.MyError) -> ()
457457
$s28implicit_lifetime_dependence10BufferViewVyA2ChYlscfC ---> {T:$s28implicit_lifetime_dependence10BufferViewVyA2ChYlscfc} implicit_lifetime_dependence.BufferView.init(lifetime dependence: scope __shared implicit_lifetime_dependence.BufferView) -> implicit_lifetime_dependence.BufferView
458458
$s28implicit_lifetime_dependence10BufferViewVyA2CYlicfC ---> {T:$s28implicit_lifetime_dependence10BufferViewVyA2CYlicfc} implicit_lifetime_dependence.BufferView.init(lifetime dependence: inherit implicit_lifetime_dependence.BufferView) -> implicit_lifetime_dependence.BufferView
459459
$s28implicit_lifetime_dependence7WrapperV8getView1AA10BufferViewVyYLsF ---> implicit_lifetime_dependence.Wrapper.getView1(self lifetime dependence: scope) () -> implicit_lifetime_dependence.BufferView
460460
$s28implicit_lifetime_dependence7WrapperV8getView2AA10BufferViewVyYLiF ---> implicit_lifetime_dependence.Wrapper.getView2(self lifetime dependence: inherit) () -> implicit_lifetime_dependence.BufferView
461+
$s3red3use2fnySiyYAXE_tF ---> red.use(fn: @isolated(any) () -> Swift.Int) -> ()

0 commit comments

Comments
 (0)