Skip to content

Commit e7c24bd

Browse files
authored
Merge pull request #63701 from tshortli/main-actor-missing-on-closure-param
AST: Print the custom attributes attached to `AttributedTypeRepr`
2 parents 6e16c07 + 7bfc448 commit e7c24bd

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

lib/AST/TypeRepr.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,15 @@ void AttributedTypeRepr::printAttrs(ASTPrinter &Printer,
218218
Printer.printSimpleAttr("@autoclosure") << " ";
219219
if (hasAttr(TAK_escaping))
220220
Printer.printSimpleAttr("@escaping") << " ";
221+
222+
for (auto customAttr : Attrs.getCustomAttrs()) {
223+
Printer.callPrintStructurePre(PrintStructureKind::BuiltinAttribute);
224+
Printer << "@";
225+
customAttr->getTypeRepr()->print(Printer, Options);
226+
Printer.printStructurePost(PrintStructureKind::BuiltinAttribute);
227+
Printer << " ";
228+
}
229+
221230
if (hasAttr(TAK_Sendable))
222231
Printer.printSimpleAttr("@Sendable") << " ";
223232
if (hasAttr(TAK_noDerivative))

test/ModuleInterface/concurrency.swift

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ public func takesSendable(
2020
_ block: @Sendable @escaping () async throws -> Void
2121
) { }
2222

23+
@available(SwiftStdlib 5.5, *)
24+
public func takesMainActor(
25+
_ block: @MainActor @escaping () -> Void
26+
) { }
27+
2328
// RUN: %target-typecheck-verify-swift -enable-experimental-concurrency -I %t
2429

2530
#else
@@ -31,12 +36,13 @@ func callFn() async {
3136
}
3237
#endif
3338

34-
// RUN: %FileCheck %s <%t/Library.swiftinterface
39+
// RUN: %FileCheck %s < %t/Library.swiftinterface
3540
// CHECK: // swift-module-flags:{{.*}} -enable-experimental-concurrency
3641
// CHECK: public func fn() async
3742
// CHECK: public func reasyncFn(_: () async -> ()) reasync
3843
// CHECK: public func takesSendable(_ block: @escaping @Sendable () async throws ->
44+
// CHECK: public func takesMainActor(_ block: @escaping @{{_Concurrency.MainActor|MainActor}} () ->
3945

40-
// RUN: %target-swift-emit-module-interface(%t/Library.swiftinterface) %s -enable-experimental-concurrency -DLIBRARY -module-name Library -module-interface-preserve-types-as-written
41-
// RUN: %target-swift-typecheck-module-from-interface(%t/Library.swiftinterface) -enable-experimental-concurrency
42-
// RUN: %FileCheck %s <%t/Library.swiftinterface
46+
// RUN: %target-swift-emit-module-interface(%t/LibraryPreserveTypesAsWritten.swiftinterface) %s -enable-experimental-concurrency -DLIBRARY -module-name LibraryPreserveTypesAsWritten -module-interface-preserve-types-as-written
47+
// RUN: %target-swift-typecheck-module-from-interface(%t/LibraryPreserveTypesAsWritten.swiftinterface) -enable-experimental-concurrency
48+
// RUN: %FileCheck %s < %t/LibraryPreserveTypesAsWritten.swiftinterface

0 commit comments

Comments
 (0)