Skip to content

Provide property source locations for @_documentation. #74404

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
Jun 14, 2024

Conversation

DougGregor
Copy link
Member

This was breaking macro expansion in the weirdest way. Fixes rdar://127206128

This was breaking macro expansion in the weirdest way. Fixes rdar://127206128
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@grynspan
Copy link
Contributor

I'm genuinely curious how this caused the breakage.

@@ -220,3 +220,8 @@ struct SomeType {
macro multipleFreestandingRoles<T>(_: T) -> Void = #externalMacro(module: "A", type: "B")
// expected-warning@-1{{external macro implementation type}}
// expected-error@-2{{macro can only have a single freestanding role}}

Copy link
Contributor

Choose a reason for hiding this comment

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

May I suggest having an additional test with the attributes in the opposite order too?

@DougGregor
Copy link
Member Author

I'm genuinely curious how this caused the breakage.

There's an optimization that grabs the full source range of the macro, including its attributes, and hands that over to the new Swift parser to perform checking on the definition. The (old, C++) Swift parser got the starting source location for @_documentation wrong, so the source code passed to the macro validation code was bogus. Swapping the order of the attributes isn't meaningful to test because it's already effectively tested by every macro declaration everywhere.

@DougGregor DougGregor merged commit 6ca531c into swiftlang:main Jun 14, 2024
3 checks passed
@DougGregor DougGregor deleted the documentation-macro-attr-loc branch June 14, 2024 00:05
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