@@ -89,17 +89,21 @@ class MacroApplication: SyntaxRewriter {
89
89
// Expand declaration macros that were parsed as macro expansion
90
90
// expressions in this context.
91
91
if case let . expr( exprItem) = item. item,
92
- let exprExpansion = exprItem. as ( MacroExpansionExprSyntax . self) ,
93
- let macro = macroSystem. macros [ exprExpansion. macro. text] ,
94
- let freestandingMacro = macro as? FreestandingDeclarationMacro . Type {
92
+ let exprExpansion = exprItem. as ( MacroExpansionExprSyntax . self) ,
93
+ let macro = macroSystem. macros [ exprExpansion. macro. text] ,
94
+ let freestandingMacro = macro as? FreestandingDeclarationMacro . Type
95
+ {
95
96
do {
96
97
let expandedDecls = try freestandingMacro. expansion (
97
- of: exprExpansion. asMacroExpansionDecl ( ) , in: & context
98
+ of: exprExpansion. asMacroExpansionDecl ( ) ,
99
+ in: & context
98
100
)
99
101
100
- newItems. append ( contentsOf: expandedDecls. map { decl in
101
- CodeBlockItemSyntax ( item: . decl( decl) )
102
- } )
102
+ newItems. append (
103
+ contentsOf: expandedDecls. map { decl in
104
+ CodeBlockItemSyntax ( item: . decl( decl) )
105
+ }
106
+ )
103
107
} catch {
104
108
// Record the error
105
109
context. diagnose (
@@ -124,20 +128,24 @@ class MacroApplication: SyntaxRewriter {
124
128
override func visit( _ node: MemberDeclListSyntax ) -> MemberDeclListSyntax {
125
129
var newItems : [ MemberDeclListItemSyntax ] = [ ]
126
130
for item in node {
127
- // Expand declaration macros, which produce zero or more declarations.
131
+ // Expand declaration macros, which produce zero or more declarations.
128
132
if let declExpansion = item. decl. as ( MacroExpansionDeclSyntax . self) ,
129
- let macro = macroSystem. macros [ declExpansion. macro. text] ,
130
- let freestandingMacro = macro as? FreestandingDeclarationMacro . Type {
133
+ let macro = macroSystem. macros [ declExpansion. macro. text] ,
134
+ let freestandingMacro = macro as? FreestandingDeclarationMacro . Type
135
+ {
131
136
do {
132
137
let expandedDecls = try freestandingMacro. expansion (
133
- of: declExpansion, in: & context
138
+ of: declExpansion,
139
+ in: & context
134
140
)
135
141
136
- newItems. append ( contentsOf: expandedDecls. map { decl in
137
- MemberDeclListItemSyntax ( decl: decl)
138
- } )
142
+ newItems. append (
143
+ contentsOf: expandedDecls. map { decl in
144
+ MemberDeclListItemSyntax ( decl: decl)
145
+ }
146
+ )
139
147
} catch {
140
- // Record the error
148
+ // Record the error
141
149
context. diagnose (
142
150
Diagnostic (
143
151
node: Syntax ( node) ,
0 commit comments