Skip to content

Commit 03e1bb2

Browse files
authored
Merge pull request #67344 from DougGregor/print-extension-macro-conformances
Print "conformances" in extension macro role
2 parents 9dcafc8 + 940870e commit 03e1bb2

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

lib/AST/Attr.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,23 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
13891389
}
13901390
Printer << "(";
13911391
Printer << getMacroRoleString(Attr->getMacroRole());
1392+
1393+
// Print conformances, if present.
1394+
auto conformances = evaluateOrDefault(
1395+
D->getASTContext().evaluator,
1396+
ResolveExtensionMacroConformances{Attr, D},
1397+
{});
1398+
if (!conformances.empty()) {
1399+
Printer << ", conformances: ";
1400+
interleave(conformances,
1401+
[&](Type type) {
1402+
type.print(Printer, Options);
1403+
},
1404+
[&] {
1405+
Printer << ", ";
1406+
});
1407+
}
1408+
13921409
if (!Attr->getNames().empty()) {
13931410
Printer << ", names: ";
13941411
interleave(

test/ModuleInterface/macros.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@
5050
@attached(accessor, names: named(init)) public macro AccessorInitFunc() = #externalMacro(module: "SomeModule", type: "AccessorInitFuncMacro")
5151

5252
// CHECK: #if compiler(>=5.3) && $Macros && $AttachedMacros
53-
// CHECK: @attached(extension) @attached(conformance) public macro AddSendable() = #externalMacro(module: "SomeModule", type: "SendableExtensionMacro")
53+
// CHECK: @attached(extension, conformances: Swift.Sendable) @attached(conformance) public macro AddSendable() = #externalMacro(module: "SomeModule", type: "SendableExtensionMacro")
5454
// CHECK-NEXT: #else
5555
// CHECK: @attached(conformance) public macro AddSendable() = #externalMacro(module: "SomeModule", type: "SendableExtensionMacro")
5656
// CHECK-NEXT: #endif
57-
@attached(extension) @attached(conformance) public macro AddSendable() = #externalMacro(module: "SomeModule", type: "SendableExtensionMacro")
57+
@attached(extension, conformances: Sendable) @attached(conformance) public macro AddSendable() = #externalMacro(module: "SomeModule", type: "SendableExtensionMacro")
5858

5959
// CHECK-NOT: internalStringify
6060
@freestanding(expression) macro internalStringify<T>(_ value: T) -> (T, String) = #externalMacro(module: "SomeModule", type: "StringifyMacro")

0 commit comments

Comments
 (0)