Commits

Doug Gregor committed b25eda36faf
Match Objective-C names in overrides as part of validation, not override checking. Previously, we were using the Objective-C names to help determine whether a declaration is an override or not. This is broken, because we should determine overrides based on the Swift rules for overriding, then (later) check that the Objective-C runtime will see the same override behavior that the Swift runtime does. Address this problem, both by taking the Objective-C selector out of the equation when matching overrides (except for diagnostic purposes) and by performing better validation of the Objective-C names for the overriding vs. overridden methods/properties. The motivating case here (from rdar://problem/18998564) is an Objective-C initializer: -(instancetype)initString:(NSString *)string; When trying to override this in a Swift subclass, one naturally writes: override init(string: String) which implicitly has the selector initWithString:. We ended up in an unfortunate place where we rejected the override (because the selectors didn't match) with a crummy diagnostic, but omitting the "override" would result in a different conflict with the superclass. Now, we'll treat this as an override and complain that one needs to rename the method by adding "@objc(initString:)" (with a Fix-It, of course). This fixes rdar://problem/18998564, but it is not ideal: the complete solution (covered by rdar://problem/19812955) involves reworking the dance between override and @objc so that we compute 'override' first (ignoring @objc-ness entirely), and let the @objc'ness of the overridden declaration both imply @objc for the overriding declaration and implicitly fix the selector. However, such a change is too risky right now, hence the radar clone. Swift SVN r25243