Commits

Doug Gregor committed 1a830fa5417
SE-0022: Deprecate string-literal-as-selector in favor of #selector. Introduce Fix-Its to aid migration from selectors spelled as string literals ("foo:bar:", which is deprecated), as well as from construction of Selector instances from string literals (Selector("foo:bar"), which is still acceptable but not recommended), to the #selector syntax. Jump through some hoops to disambiguate method references if there are overloads: fixits.swift:51:7: warning: use of string literal for Objective-C selectors is deprecated; use '#selector' instead _ = "overloadedWithInt:" as Selector ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #selector(Bar.overloaded(_:) as (Bar) -> (Int) -> ()) In the cases where we cannot provide a Fix-It to a #selector expression, we wrap the string literal in a Selector(...) construction to suppress the deprecation warning. These are also easily searchable in the code base. This also means we're doing more validation of the string literals that go into Selector, i.e., that they are well-formed selectors and that we know about some method that is @objc and has that selector. We'll warn if either is untrue.