Skip to content

Commit 502082d

Browse files
committed
Fix remangling isolated(any) function types from type metadata.
1 parent 6b2fb2e commit 502082d

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

stdlib/public/runtime/Demangle.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,9 @@ swift::_swift_buildDemanglingForMetadata(const Metadata *type,
758758
Dem.createNode(Node::Kind::GlobalActorFunctionType);
759759
globalActorNode->addChild(globalActorTypeNode, Dem);
760760
funcNode->addChild(globalActorNode, Dem);
761+
} else if (func->getExtendedFlags().isIsolatedAny()) {
762+
funcNode->addChild(Dem.createNode(
763+
Node::Kind::IsolatedAnyFunctionType), Dem);
761764
}
762765
switch (func->getDifferentiabilityKind().Value) {
763766
case FunctionMetadataDifferentiabilityKind::NonDifferentiable:

test/Runtime/metadata_printing.swift

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-build-swift -target %target-future-triple -parse-stdlib %s -module-name main -o %t/a.out
3+
// RUN: %target-codesign %t/a.out
4+
// RUN: %target-run %t/a.out
5+
// REQUIRES: executable_test
6+
// REQUIRES: concurrency
7+
// UNSUPPORTED: use_os_stdlib
8+
// UNSUPPORTED: back_deployment_runtime
9+
10+
import Swift
11+
import StdlibUnittest
12+
import _Concurrency
13+
14+
let MetadataPrintingTests = TestSuite("MetadataPrinting")
15+
16+
class NonSendable {
17+
var x: Int = 0
18+
}
19+
20+
func expect<T>(type: T.Type, printsAs string: String) {
21+
expectEqual(string, "\(type)")
22+
}
23+
24+
MetadataPrintingTests.test("@isolated(any) functions") {
25+
expect(type: (@isolated(any) () -> ()).self,
26+
printsAs: "@isolated(any) () -> ()")
27+
expect(type: (@isolated(any) () -> NonSendable).self,
28+
printsAs: "@isolated(any) () -> NonSendable")
29+
expect(type: (@isolated(any) () -> sending NonSendable).self,
30+
printsAs: "@isolated(any) () -> sending NonSendable")
31+
}
32+
33+
MetadataPrintingTests.test("global actor functions") {
34+
expect(type: (@MainActor () -> ()).self,
35+
printsAs: "@MainActor () -> ()")
36+
expect(type: (@MainActor () -> NonSendable).self,
37+
printsAs: "@MainActor () -> NonSendable")
38+
expect(type: (@MainActor () -> sending NonSendable).self,
39+
printsAs: "@MainActor () -> sending NonSendable")
40+
}
41+
42+
runAllTests()

0 commit comments

Comments
 (0)