Skip to content

[ASTScope] Adjust parent location for peer macro to after its attached decl. #64892

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
Apr 4, 2023

Conversation

DougGregor
Copy link
Member

Peer macro produce declarations that are semantically alongside the declaration to which the macro is attached. However, the source location used for constructing the scope tree was based on the attribute itself, which meant it was inside the scope of the declaration to which the macro was attached. This lead to incorrect unqualified name lookup; in the example that's now a test case, this meant that the Self of the protocol to which the macro was attached was visible from within the peer declaration. Hilarity (in the form of a type checker crash) ensued.

Fix the location used for constructing the scope tree of peer macros to be right after the attached declaration. Fixes rdar://107228586.

…d decl.

Peer macro produce declarations that are semantically alongside the
declaration to which the macro is attached. However, the source
location used for constructing the scope tree was based on the
attribute itself, which meant it was inside the scope of the
declaration to which the macro was attached. This lead to incorrect
unqualified name lookup; in the example that's now a test case, this
meant that the `Self` of the protocol to which the macro was attached
was visible from within the peer declaration. Hilarity (in the form of
a type checker crash) ensued.

Fix the location used for constructing the scope tree of peer macros to
be right after the attached declaration. Fixes rdar://107228586.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor DougGregor merged commit 1715963 into swiftlang:main Apr 4, 2023
@DougGregor DougGregor deleted the peer-macro-scope-tree-fix branch April 4, 2023 16:03
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