I'm in the process of converting a project to Swift 3, and I've run into a weird conflict with the automatic renaming of Objective-C methods into Swift.
- I have a Objective-C protocol Foo that declares a required method -(void)clearListSelection.
- I have an Objective-C class FooController with a public method matching that selector.
- I have a Swift class BarController that inherits form FooController, and declares conformance to the Foo protocol.
Previously, this was all fine (as it would be if all parts were Objective-C). Now, the compiler "helpfully" renames the required method to clearSelection() in Swift. Thus:
- BarController no longer conforms to Foo, because it doesn't implement the required method.
- I can't add a method clearListSelection() to BarController, because the compiler says I need to override the inherited method.
- Once I add that keyword, the compiler complains that the method has been renamed.
- If I try to override clearSelection(), the compiler complains that there is no such method in the superclass.
- And if I take off the override, it tells me the method has an Objective-C selector that conflicts with a method from its superclass.
So, the compiler seems to be smart enough to prevent me from taking a number of bad paths, but not smart enough to recognize the good path. It's hard for me to tell whether this is a bug, or something Swift 3 is deliberately making impossible. 😐
It does appear to be the case that I can add an NS_SWIFT_NAME attribute to the protocol declaration to get the compiler to stop "fixing" the name. But this still feels wrong to me.