Skip to content

Commit 9778e1a

Browse files
committed
[Reflection] Improve dumping and test global-actor-qualified function types
1 parent ff24437 commit 9778e1a

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

stdlib/public/Reflection/TypeRef.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,19 @@ class PrintTypeRef : public TypeRefVisitor<PrintTypeRef, void> {
137137
break;
138138
}
139139

140+
if (auto globalActor = F->getGlobalActor()) {
141+
fprintf(file, "\n");
142+
Indent += 2;
143+
printHeader("global-actor");
144+
{
145+
Indent += 2;
146+
printRec(globalActor);
147+
fprintf(file, ")");
148+
Indent -= 2;
149+
}
150+
Indent += 2;
151+
}
152+
140153
fprintf(file, "\n");
141154
Indent += 2;
142155
printHeader("parameters");
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public struct UsesConcurrency {
2+
public var mainActorFunction: @MainActor () -> Void
3+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// REQUIRES: no_asan
2+
// REQUIRES: executable_test
3+
// REQUIRES: concurrency
4+
// REQUIRES: libdispatch
5+
6+
// rdar://76038845
7+
// UNSUPPORTED: use_os_stdlib
8+
// UNSUPPORTED: back_deployment_runtime
9+
10+
// RUN: %empty-directory(%t)
11+
12+
// RUN: %target-build-swift -Xfrontend -enable-anonymous-context-mangled-names %S/Inputs/ConcurrencyTypes.swift -parse-as-library -emit-module -emit-library -module-name TypesToReflect -o %t/%target-library-name(TypesToReflect)
13+
// RUN: %target-build-swift -Xfrontend -enable-anonymous-context-mangled-names %S/Inputs/ConcurrencyTypes.swift %S/Inputs/main.swift -emit-module -emit-executable -module-name TypesToReflect -o %t/TypesToReflect
14+
15+
// RUN: %target-swift-reflection-dump -binary-filename %t/%target-library-name(TypesToReflect) | %FileCheck %s
16+
// RUN: %target-swift-reflection-dump -binary-filename %t/TypesToReflect | %FileCheck %s
17+
18+
// CHECK: FIELDS:
19+
// CHECK: =======
20+
// CHECK: TypesToReflect.UsesConcurrency
21+
// CHECK: ------------------
22+
// CHECK: mainActorFunction: @Swift.MainActor () -> ()
23+
// CHECK: (function
24+
// CHECK: (global-actor
25+
// CHECK: (class Swift.MainActor))

0 commit comments

Comments
 (0)