-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
class_delegate_protocol should accept AnyObject #1261
Comments
I didn't know you could use @jshier Would you like to send a PR? |
@marcelofabri I've never worked with this codebase before, so what would you recommend I do? I've found the rule (I think it should be renamed to |
Thinking about this more, it seems like the rule also needs to account for inheriting from a protocol that requires reference semantics. Currently it doesn't check if the protocol inherits at all, so this seems like it would be a major change. |
I don't think we should rename it by now.
Actually, it does check the inherited protocol: https://github.com/realm/SwiftLint/blob/master/Source/SwiftLintFramework/Rules/ClassDelegateProtocolRule.swift#L56. But it only checks for |
Without being able to detect whether the inherited protocol inherits from one that guarantees reference semantics (or even just the That said, I can look into making a set of accepted base types that guarantee reference semantics, but it likely won't be exhaustive, especially since inheriting from any Apple protocol does the same thing. So, I can do the base types but that's hardly exhaustive. |
I'm not too worried about false positives, since the rule only validates My guess is that 95%+ of the cases where a
|
I've been able to make the changes (essentially just changing the class protocol regex: |
Opened #1265 to fix this. |
Fixed in #1279 |
Using
AnyObject
instead ofclass
gives the protocol the same reference requirement and is future proof against the discussed removal of theclass
keyword. It shouldn't trigger the warning.The text was updated successfully, but these errors were encountered: