Skip to content

[Macros] Requestify MacroExpansionExpr expansion #65453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Apr 27, 2023

The request returns the expanded buffer ID even if it failed to typecheck the expanded buffer.
This makes refactoring 'Expand Macro' work regardless of the typechecking results.

rdar://108530760

@rintaro
Copy link
Member Author

rintaro commented Apr 27, 2023

@swift-ci Please smoke test

@rintaro rintaro force-pushed the macros-expandexpr-request-rdar108530760 branch from 73a82e6 to c9fb369 Compare April 27, 2023 16:49
@rintaro
Copy link
Member Author

rintaro commented Apr 27, 2023

@swift-ci Please smoke test

ExpandMacroExpansionExprRequest::evaluate(Evaluator &evaluator,
MacroExpansionExpr *mee) const {
assert(mee->getMacroRef() && "MacroRef should be set before expansion");
return expandMacroExpr(mee);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove expandMacroExpr and move its implementation into here? All callers should be using the request right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but in this PR, I'd like to follow the scheme of ExpandMacroExpansionDeclRequest/expandFreestandingMacro().

@@ -265,3 +269,6 @@ macro anonymousTypes(_: () -> String) = #externalMacro(module: "MacroDefinition"
// RUN: %sourcekitd-test -req=format -line=23 -length=1 %s | %FileCheck -check-prefix=FORMATTED %s
// FORMATTED: " var x: Int"

//##-- Expansion on "fails to typecheck" macro expression
// RUN: %sourcekitd-test -req=refactoring.expand.macro -pos=61:2 %s -- ${COMPILER_ARGS[@]} | %FileCheck -check-prefix=ERRNEOUS_EXPAND %s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: ERRONEOUS

@rintaro rintaro force-pushed the macros-expandexpr-request-rdar108530760 branch from c9fb369 to f6bdd26 Compare April 27, 2023 18:27
@rintaro
Copy link
Member Author

rintaro commented Apr 27, 2023

@swift-ci Please smoke test

@rintaro rintaro force-pushed the macros-expandexpr-request-rdar108530760 branch from f6bdd26 to ec07e83 Compare April 27, 2023 21:39
The request returns the expanded buffer ID even if it failed to
typecheck the expanded buffer.
This makes refactoring 'Expand Macro' work regardless of the
typechecking results.

rdar://108530760
@rintaro rintaro force-pushed the macros-expandexpr-request-rdar108530760 branch from ec07e83 to 35db928 Compare April 27, 2023 21:40
@rintaro
Copy link
Member Author

rintaro commented Apr 27, 2023

@swift-ci Please smoke test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants