Skip to content

[IDE] Visit auxiliary declarations if walking expansions #66421

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 8, 2023

Conversation

bnbarham
Copy link
Contributor

@bnbarham bnbarham commented Jun 7, 2023

After visiting declarations, also walk into their auxiliary decls if expansions are being walked.

Resolves rdar://109548265.

@bnbarham bnbarham requested a review from hamishknight June 7, 2023 18:29
@bnbarham bnbarham requested review from ahoppen and rintaro as code owners June 7, 2023 18:29
@bnbarham
Copy link
Contributor Author

bnbarham commented Jun 7, 2023

@swift-ci please test

@bnbarham bnbarham force-pushed the index-macro-conformances branch from 132fc92 to 4909e6b Compare June 7, 2023 21:33
Comment on lines 463 to 465
if (!doIt(expr))
alreadyFailed = true;
alreadyFailed = doIt(expr);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hamishknight do you have the refactoring itch again by any chance :)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Heh, maybe one day, also need to do SourceEntityWalker :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So. Fun story. These were actually correct. They were checking for nullptr, not for bool. doIt(Decl*) returns true on failure. The others return nullptr. Yay implicit conversions.

@bnbarham
Copy link
Contributor Author

bnbarham commented Jun 7, 2023

@swift-ci please test

Comment on lines +244 to +246
if (shouldWalkMacroArgumentsAndExpansion().second) {
D->visitAuxiliaryDecls([&](Decl *auxDecl) {
if (Action.Action == PostWalkAction::Stop)
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity, I wonder how bad it would be if the ASTWalker did this by default when visiting a Decl? Does seem kind of weird that it will visit some expansions but not others when you ask it to walk expansions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I originally put it in Decl::walk (#66399). That's incorrect since doIt is called directly in the walk and thus we'd miss visiting auxiliary decls on members (note the test I added since then).

I could have moved to eg. doIt(Decl *) but there's callers that really expect to just walk the given node (eg. TypeCheckFunctionBodyRequest calls performAbstractFuncDeclDiagnostics), so that also doesn't work. So I went with the easier change of only impacting SourceEntityWalker, which only has a couple uses that walk expansions.

Also odd is that we walk into the extension while possible within a type, rather than at the top level.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hrm yeah, that's fair

@bnbarham bnbarham force-pushed the index-macro-conformances branch from 4909e6b to d281c7e Compare June 8, 2023 02:39
After visiting declarations, also walk into their auxiliary decls if
expansions are being walked.

Resolves rdar://109548265.
@bnbarham bnbarham force-pushed the index-macro-conformances branch from d281c7e to b3af130 Compare June 8, 2023 03:06
@bnbarham
Copy link
Contributor Author

bnbarham commented Jun 8, 2023

@swift-ci please test

@bnbarham bnbarham merged commit 7b74f72 into swiftlang:main Jun 8, 2023
@bnbarham bnbarham deleted the index-macro-conformances branch June 8, 2023 15:26
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.

4 participants