Skip to content

Check protocols for selector conflicts #41828

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

Conversation

beccadax
Copy link
Contributor

Although we have always checked classes to see if their @objc members had the same selectors, it turns out we never did this for protocols. Oops. Keep a table of ObjC selector names for protocols, just as we do for classes, and diagnose any conflicts between them.

Fixes rdar://80990066.

This prepares us to generalize ObjC selector collision diagnostics to also include protocols. NFC in this commit because, even though Sema and ClangImporter now try to record ObjC methods on non-`ClassDecl`s, `NominalTypeDecl::createObjCMethodLookup()` still doesn’t create ObjC method tables for them, so the calls are no-ops.
Although we have always checked classes to see if their @objc members had the same selectors, it turns out we never did this for protocols. Oops. Keep a table of ObjC selector names for protocols, just as we do for classes, and diagnose any conflicts between them.

Fixes rdar://80990066.
@beccadax beccadax force-pushed the a-breach-of-protocol-can-cause-a-conflict branch from a964bdb to 06949a4 Compare March 16, 2022 21:44
@beccadax
Copy link
Contributor Author

@swift-ci please smoke test

@beccadax
Copy link
Contributor Author

@swift-ci please test source compatibility

@beccadax
Copy link
Contributor Author

@swift-ci please smoke test

@beccadax
Copy link
Contributor Author

Linux failure looks like an infrastructure issue.

@swift-ci please smoke test Linux platform

@beccadax
Copy link
Contributor Author

@swift-ci please test source compatibility

@beccadax beccadax requested a review from hamishknight March 20, 2022 23:35
@beccadax
Copy link
Contributor Author

The source compatibility suite failures appear to match e.g. https://ci.swift.org/job/swift-main-source-compat-suite/12/, which was run at the same time, so I think they are unrelated.

There appear to have been no instances of this new warning in the source compatibility suite.

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.

2 participants