Skip to content

Support body macros that don’t return any statements #2775

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
merged 1 commit into from
Aug 8, 2024

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Aug 5, 2024

Previously, when a body macro returned no statements, we would return an empty expansion and not add the braces in collapse. Fix that.

@ahoppen ahoppen requested a review from bnbarham as a code owner August 5, 2024 23:22
@ahoppen
Copy link
Member Author

ahoppen commented Aug 5, 2024

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Aug 7, 2024

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Aug 7, 2024

@swift-ci Please test Windows

@ahoppen ahoppen requested a review from rintaro August 7, 2024 22:04
func f() {}
""",
expandedSource: """
func f() {}
Copy link
Member

Choose a reason for hiding this comment

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

Is expected behavior is replacing the body in the original code to {}? If so, could you add some statements in the original source code?

Copy link
Member Author

Choose a reason for hiding this comment

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

It’s expected to leave the body untouched. This matches the behavior of accessors

I updated the test.

Previously, when a body macro returned no statements, we would return an empty expansion and not add the braces in `collapse`. Fix that.
@ahoppen
Copy link
Member Author

ahoppen commented Aug 8, 2024

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Aug 8, 2024

@swift-ci Please test Windows

@ahoppen ahoppen merged commit d992e0d into swiftlang:main Aug 8, 2024
3 checks passed
@ahoppen ahoppen deleted the empty-body-macro branch August 8, 2024 21:57
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.

2 participants