-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Warn about async-imported selector conflicts #59743
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
Conversation
The change in swiftlang#59479 inadvertently fixed another bug in selector conflict checking: Swift did not notice when an ObjC header declared an async-imported method, but a Swift extension to the same class added another method with the same selector. Unfortunately, fixing this bug was source-breaking, and it also caused Swift to diagnose spurious conflicts between the various names that a single ObjC method might be imported with. Soften the error to a warning in Swift 5 mode and suppress the spurious diagnostics. Fixes rdar://95887113.
@swift-ci please smoke test |
@swift-ci please test source compatibility |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Been a little while since I've worked in this area, I'm not sure I fully understand why this issue doesn't come up for the non-async-alternative imported version, but this LGTM modulo the question on ordering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Have a question though!
Refactor ObjC conflict diagnosis code to sort conflict data more thoroughly, filter out unwanted declarations earlier, and just generally behave in ways that are more likely to work correctly. This change increases the determinism of the ordering of diagnostics and the selection of the “correct” declaration that the others are considered to conflict with, increasing my confidence that the diagnostics will work correctly in untested corner cases or if the compiler is refactored so that declarations are recorded in a different order. It also adds a new selection rule—@objc without vs. with explicit selector—that I believe will slightly improve the diagnostics we produce. And it replaces a lot of really dodgy-looking logic that may have only worked reliably when a conflict involved exactly two methods.
a8a614d
to
8c9a6ce
Compare
@swift-ci please smoke test |
@swift-ci please test source compatibility |
When I looked more closely at the existing code, I became less and less convinced that it would reliably do the right thing when there were more than two methods involved in a conflict, so I’ve rewritten the function to work in a way that I think will be more reliable. This perturbed a bunch of tests (!), so I also added a new rule to the set used to choose which method “should” have the selector. It’s a bigger diff than I want, but I’m much more confident that it will work correctly in cases we don’t directly test. |
The change in #59479 inadvertently fixed another bug in selector conflict checking: Swift did not notice when an ObjC header declared an async-imported method, but a Swift extension to the same class added another method with the same selector. Unfortunately, fixing this bug was source-breaking, and it also caused Swift to diagnose spurious conflicts between the various names that a single ObjC method might be imported with. Soften the error to a warning in Swift 5 mode and suppress the spurious diagnostics.
Fixes rdar://95887113.