Skip to content

Commit 8c6ba04

Browse files
committed
Print "conformances" in extension macro role
Fixes rdar://112297735.
1 parent b647966 commit 8c6ba04

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
@@ -1383,6 +1383,23 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
13831383
}
13841384
Printer << "(";
13851385
Printer << getMacroRoleString(Attr->getMacroRole());
1386+
1387+
// Print conformances, if present.
1388+
auto conformances = evaluateOrDefault(
1389+
D->getASTContext().evaluator,
1390+
ResolveExtensionMacroConformances{Attr, D},
1391+
{});
1392+
if (!conformances.empty()) {
1393+
Printer << ", conformances: ";
1394+
interleave(conformances,
1395+
[&](Type type) {
1396+
type.print(Printer, Options);
1397+
},
1398+
[&] {
1399+
Printer << ", ";
1400+
});
1401+
}
1402+
13861403
if (!Attr->getNames().empty()) {
13871404
Printer << ", names: ";
13881405
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)