-
Notifications
You must be signed in to change notification settings - Fork 441
Fix trivia transfer bugs for freestanding expression macros #2048
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
Fix trivia transfer bugs for freestanding expression macros #2048
Conversation
@swift-ci Please test |
9f0e185
to
486b5c2
Compare
@swift-ci Please test |
@bnbarham I removed the entire comment-handling logic altogether because it wasn’t really working as I intended and it didn’t match what the “Inline Macro” refactoring does. Could you take another look at this PR? |
@swift-ci Please test Windows |
So IIUC we leave the trivia and pass it through now? |
/// freestanding macro that separate it from the previous declarations. | ||
/// We need to do this because we are replacing the entire macro expansion | ||
/// declaration / expression with the expanded source but the “Inline Macro” | ||
/// refactoring only replaces the node’s content, and doesn’t touch its trivia. | ||
func wrappingInNonCommentTrivia(from node: some SyntaxProtocol) -> String { |
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.
Still called wrappingInNonCommentTrivia
. I don't think it's necessary to mention inline macro here. There's no reason we couldn't change it as well.
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.
Thanks for catching these things, as always
486b5c2
to
6b6b157
Compare
There were two bugs in the way we transferred trivia from the original macro expansion expression to the expanded expression. 1. We were attaching the stripped leading trivia to the end of the node 2. We weren’t resetting the `lineContainedComment` and `lineContainedNonWhitespaceNonComment` variables when seeing a newline in a comment-only line (1) is easy to fix. For (2), I just remove the entire comment-handling logic because it didn’t match what “Inline Macro” was doing anyway. rdar://113639097
6b6b157
to
5824002
Compare
@swift-ci Please test |
@swift-ci Please test Windows |
1 similar comment
@swift-ci Please test Windows |
There were two bugs in the way we transferred trivia from the original macro expansion expression to the expanded expression.
lineContainedComment
andlineContainedNonWhitespaceNonComment
variables when seeing a newline in a comment-only linerdar://113639097