File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
lib/ASTGen/Sources/ASTGen Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -169,10 +169,16 @@ func evaluateMacro(
169
169
switch macroPtr. pointee. macro {
170
170
// Handle expression macro.
171
171
case let exprMacro as ExpressionMacro . Type :
172
- guard let parentExpansion = parentSyntax. as ( MacroExpansionExprSyntax . self) else {
173
- print ( " not on a macro expansion node: \( token. recursiveDescription) " )
172
+ let parentExpansion : MacroExpansionExprSyntax
173
+ if let expansionExpr = parentSyntax. as ( MacroExpansionExprSyntax . self) {
174
+ parentExpansion = expansionExpr
175
+ } else if let expansionDecl = parentSyntax. as ( MacroExpansionDeclSyntax . self) {
176
+ parentExpansion = expansionDecl. asMacroExpansionExpr ( )
177
+ } else {
178
+ print ( " not on a macro expansion node: \( parentSyntax. recursiveDescription) " )
174
179
return - 1
175
180
}
181
+
176
182
macroName = parentExpansion. macro. withoutTrivia ( ) . description
177
183
evaluatedSyntax = Syntax ( try exprMacro. expansion ( of: parentExpansion, in: & context) )
178
184
You can’t perform that action at this time.
0 commit comments