Commits

Doug Gregor committed bc158c31bf3
[Sema] Improve diagnostics for witness mismatches against @objc protocols. Simplify and improve the checking of @objc names when matching a witness to a requirement in the @objc protocol. First, don't use @objc-ness as part of the initial screening to determine whether a witness potentially matches an @objc requirement: we will only reject a potential witness when the potential witness has an explicit "@nonobjc" attribute on it. Otherwise, the presence of @objc and the corresponding Objective-C name is checked only after selecting a candidate. This more closely mirrors what we do for override checking, where we match based on the Swift names (first) and validate @objc'ness afterward. It is also a stepping stone to inferring @objc'ness and @objc names from protocol conformances. Second, when emitting a diagnostic about a missing or incorrect @objc annotation, make sure the Fix-It gets the @objc name right: this might mean adding the Objective-C name along with @objc (e.g., "@objc(fooWithString:bar:)"), adding the name to an unadorned-but-explicit "@objc" attribute, or fixing the name of an @objc attribute (e.g., "@objc(foo:bar:)" becomes @objc(fooWithString:bar:)"). Make this diagnostic an error, rather than a note on a generic "does not conform" diagnostic, so it's much easier to see the diagnostic and apply the Fix-It. Third, when emitting the warning about a non-@objc near-match for an optional @objc requirement, provide two Fix-Its: one that adds the appropriate @objc annotation (per the paragraph above), and one that adds @nonobjc to silence the warning. Part of the QoI improvements for conformances to @objc protocols, rdar://problem/25159872.