[6.4.x] ClangImporter: Avoid mirroring protocol members that are declared elsewhere#89451
Open
tshortli wants to merge 3 commits into
Open
[6.4.x] ClangImporter: Avoid mirroring protocol members that are declared elsewhere#89451tshortli wants to merge 3 commits into
tshortli wants to merge 3 commits into
Conversation
Contributor
Author
|
@swift-ci please test Linux |
Use -verify-additional-prefix to parameterize matching expected diagnostics rather than resorting to FileCheck. Also, check swift-ide-test output in the test to make it easier to see exactly what ClangImporter is doing.
…ewhere. When an ObjC class in an imported Clang module conforms to an ObjC protocol whose requirement shares a selector with an existing, concrete method already declared on the class or a nearby category, SwiftDeclConverter would still synthesize a "mirrored" method. During name lookup and overload resolution, the mirror implementation could be picked instead of the concrete implementation. Prior to MemberImportVisibility, the fact that the compiler chooses the mirrored method was typically invisible to developers under most circumstances. However, with MemberImportVisibility this behavior resulted in unexpected diagnostics requiring developers to import another module. Skip mirroring when the interface, or a category in the same module as either the interface or the conformance, already declares a concrete (non-accessor) method with the same selector. Property accessors don't count: a property only exposes the member via property syntax, so the mirror is still needed for method-call syntax. The existing property-mirroring path already had an analogous check; the two now share a helper. Resolves rdar://166912341.
204f0cd to
34833eb
Compare
Contributor
Author
|
@swift-ci please test |
nkcsgexi
approved these changes
May 27, 2026
hnrklssn
approved these changes
May 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SwiftDeclConverterwould still synthesize a "mirrored" method. During name lookup and overload resolution, the mirror implementation could be picked instead of the concrete implementation. Prior to MemberImportVisibility, the fact that the compiler chooses the mirrored method was typically invisible to developers under most circumstances. However, with MemberImportVisibility this behavior resulted in unexpected diagnostics requiring developers to import another module. The fix is to skip mirroring when the interface, or a category in the same module as either the interface or the conformance, already declares a concrete (non-accessor) method with the same selector.