Skip to content

Commit 7fb1ba9

Browse files
committed
[AST printer] Stop printing -> () types on all macro declarations.
1 parent c78afdc commit 7fb1ba9

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4811,16 +4811,14 @@ void PrintAST::visitMacroDecl(MacroDecl *decl) {
48114811
}
48124812
);
48134813

4814-
{
4814+
if (decl->resultType.getTypeRepr() ||
4815+
!decl->getResultInterfaceType()->isVoid()) {
48154816
Printer.printStructurePre(PrintStructureKind::DeclResultTypeClause);
48164817
SWIFT_DEFER {
48174818
Printer.printStructurePost(PrintStructureKind::DeclResultTypeClause);
48184819
};
48194820

4820-
if (decl->parameterList)
4821-
Printer << " -> ";
4822-
else
4823-
Printer << ": ";
4821+
Printer << " -> ";
48244822

48254823
TypeLoc resultTypeLoc(
48264824
decl->resultType.getTypeRepr(), decl->getResultInterfaceType());

test/ModuleInterface/macros.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
@freestanding(expression) public macro publicLine<T: ExpressibleByIntegerLiteral>() -> T = #externalMacro(module: "SomeModule", type: "Line")
3131

3232
// CHECK: #if compiler(>=5.3) && $Macros
33-
// CHECK: @attached(accessor) public macro myWrapper() -> () = #externalMacro(module: "SomeModule", type: "Wrapper")
33+
// CHECK: @attached(accessor) public macro myWrapper() = #externalMacro(module: "SomeModule", type: "Wrapper")
3434
// CHECK-NEXT: #endif
3535
@attached(accessor) public macro myWrapper() = #externalMacro(module: "SomeModule", type: "Wrapper")
3636

3737
// CHECK: #if compiler(>=5.3) && $Macros && $AttachedMacros
38-
// CHECK: @attached(member, names: named(`init`), prefixed(`$`)) public macro MemberwiseInit() -> () = #externalMacro(module: "SomeModule", type: "MemberwiseInitMacro")
38+
// CHECK: @attached(member, names: named(`init`), prefixed(`$`)) public macro MemberwiseInit() = #externalMacro(module: "SomeModule", type: "MemberwiseInitMacro")
3939
// CHECK-NEXT: #endif
40-
@attached(member, names: named(init), prefixed(`$`)) public macro MemberwiseInit() -> () = #externalMacro(module: "SomeModule", type: "MemberwiseInitMacro")
40+
@attached(member, names: named(init), prefixed(`$`)) public macro MemberwiseInit() = #externalMacro(module: "SomeModule", type: "MemberwiseInitMacro")
4141

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

0 commit comments

Comments
 (0)