[FixCode] Apply #selector fixits

These are very useful fixits for migration. Note: this applies the
fixits for selectors that are actually found, but not the one that wraps
an arbitrary string literal in Selector(...), because that one indicates
a possibly missing selector that the user should review.

rdar://problem/26678232
This commit is contained in:
Ben Langmuir
2016-07-05 10:48:13 -07:00
parent 3b80925c14
commit cb4b1b601b
3 changed files with 31 additions and 1 deletions

View File

@@ -595,7 +595,9 @@ private:
Info.ID == diag::function_type_no_parens.ID || Info.ID == diag::function_type_no_parens.ID ||
Info.ID == diag::convert_let_to_var.ID || Info.ID == diag::convert_let_to_var.ID ||
Info.ID == diag::parameter_extraneous_double_up.ID || Info.ID == diag::parameter_extraneous_double_up.ID ||
Info.ID == diag::attr_decl_attr_now_on_type.ID) Info.ID == diag::attr_decl_attr_now_on_type.ID ||
Info.ID == diag::selector_construction_suggest.ID ||
Info.ID == diag::selector_literal_deprecated_suggest.ID)
return true; return true;
return false; return false;
} }

View File

@@ -0,0 +1,14 @@
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -disable-objc-attr-requires-foundation-module -parse %s -emit-fixits-path %t.remap
// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %s.result
import ObjectiveC
// REQUIRES: objc_interop
@objc class Selectors {
func takeSel(_: Selector) {}
func mySel() {}
func test() {
takeSel("mySel")
takeSel(Selector("mySel"))
}
}

View File

@@ -0,0 +1,14 @@
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -disable-objc-attr-requires-foundation-module -parse %s -emit-fixits-path %t.remap
// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %s.result
import ObjectiveC
// REQUIRES: objc_interop
@objc class Selectors {
func takeSel(_: Selector) {}
func mySel() {}
func test() {
takeSel(#selector(Selectors.mySel))
takeSel(#selector(Selectors.mySel))
}
}