Skip to content
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

Compute the lexical context of an accessor macro based on the pre-rewritten node #2936

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Jan 10, 2025

When an accessor macro contains a closure, it gets rewritten to a new node in MacroSystem by calling super.visit. That rewritten node doesn’t have any parents (because SyntaxRewriter is expecting that node to get inserted into the tree when the node’s parent gets rewritten). This caused us to generate an empty lexical context in these situations.

To fix this, generate the lexical context based on the node before we rewrite it.

rdar://142639902

…ritten node

When an accessor macro contains a closure, it gets rewritten to a new node in `MacroSystem` by calling `super.visit`. That rewritten node doesn’t have any parents (because `SyntaxRewriter` is expecting that node to get inserted into the tree when the node’s parent gets rewritten). This caused us to generate an empty lexical context in these situations.

To fix this, generate the lexical context based on the node before we rewrite it.

rdar://142639902
@ahoppen ahoppen requested a review from bnbarham as a code owner January 10, 2025 08:26
@ahoppen
Copy link
Member Author

ahoppen commented Jan 10, 2025

@swift-ci Please test

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.

1 participant