Skip to content

[cxx-interop] Fix spurious ambiguous member lookup #78132

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 9 commits into from
Dec 17, 2024

Conversation

j-hui
Copy link
Contributor

@j-hui j-hui commented Dec 12, 2024

Nested calls to importBaseMemberDecl() subvert its cache and compromise its idempotence, causing the semantic checker to spuriously report ambiguous member lookups when multiple ClangRecordMemberLookup requests are made (e.g., because of an unrelated missing member lookup).

One such scenario is documented in the test case I checked into the test suite in f818a5d, which fails without this fix (in particular, inherited-lookup-typechecker.swift fails because of the expected error from the missing member; inherited-lookup-executable.swift works because it does not attempt to access a missing member).

I noticed this bug in #77726 when I found that my expected-errors seemed to be triggering this unrelated error. I'm breaking out a small piece of that PR because (1) it is getting quite large, (2) it is getting stale, and (3) I am trying to separate this bug fix from that feature work.

rdar://141069984

@j-hui
Copy link
Contributor Author

j-hui commented Dec 12, 2024

Another reason I'm opening this PR separate from #77726 is because I want to test it independently in CI. This change seems to cause a cascade of other issues, apparently because the existing tests have come to depend on nested calls to importBaseMemberDecl(); each layer of nesting synthesizes another (unnecessary) shim call, with an even longer identifier.

As such, @swift-ci please test

@j-hui
Copy link
Contributor Author

j-hui commented Dec 12, 2024

@swift-ci please test

Also include a little more of the mangled symbol, for more precise
testing + better readability of the `// CHECK: ` directives (though they
are still pretty unreadable)
@j-hui
Copy link
Contributor Author

j-hui commented Dec 12, 2024

@swift-ci Please smoke test

@j-hui j-hui changed the title Fix spurious ambiguous member lookup [cxx-interop] Fix spurious ambiguous member lookup Dec 12, 2024
@j-hui
Copy link
Contributor Author

j-hui commented Dec 12, 2024

@swift-ci Please test

@j-hui j-hui marked this pull request as ready for review December 12, 2024 23:36
@j-hui
Copy link
Contributor Author

j-hui commented Dec 13, 2024

@swift-ci Please test

@fahadnayyar fahadnayyar self-requested a review December 13, 2024 17:45
@j-hui
Copy link
Contributor Author

j-hui commented Dec 16, 2024

@swift-ci Please test

@j-hui
Copy link
Contributor Author

j-hui commented Dec 17, 2024

@swift-ci Please test

Copy link
Contributor

@Xazax-hun Xazax-hun left a comment

Choose a reason for hiding this comment

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

LGTM!

@j-hui j-hui merged commit 796075a into swiftlang:main Dec 17, 2024
5 checks passed
@j-hui j-hui deleted the fix-inherited-member-lookup branch December 17, 2024 19:40
j-hui added a commit that referenced this pull request Jan 22, 2025
…ed members (#78673)

Follow-up from #78132, which did not fix issues related to eagerly imported members like subscripts.

This patch restructures recursive ClangRecordMemberLookup requests to importBaseMemberDecl() in the recursive calls, rather than propagating base member decls up to the initial lookup request and doing the import. Doing so seems to fix lingering resolution issues (which I've added to the regression tests).

rdar://141069984
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.

3 participants