-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
[Sema] A couple of fixes for MiscDiagnostics on macro expansions #77479
[Sema] A couple of fixes for MiscDiagnostics on macro expansions #77479
Conversation
af123d9
to
3d4acb0
Compare
Going to drop the |
@swift-ci please test source compatibility |
Avoid walking into macro expansions for MiscDiagnostics, the expansions will instead be visited when they're type-checked on their own.
Always bothered me the constructor for ExprRewriter is buried in the middle of the class.
Attempting to expand macros in the middle of CSApply can result in attempting to run MiscDiagnostics within a closure that hasn't yet had the solution applied to the AST, which can crash the implicit-self diagnostic logic. Move the expansion to the end of CSApply such that expansions are type-checked along with local decls, ensuring it's run after the solution has been applied to the AST. rdar://138997009
3d4acb0
to
9c3b8a6
Compare
@swift-ci please test |
return MacroWalking::Expansion; | ||
// Macro expansions will be walked when they're type-checked, not as | ||
// part of the surrounding code. | ||
return MacroWalking::None; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please separately evaluate whether it would be possible to subtype all of this walkers from BaseDiagnosticWalker
and remove all of these overrides?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh, I have that exact change in a follow-up PR :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect! :)
rdar://138997009