Skip to content

Commit cb4b1b6

Browse files
committed
[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
1 parent 3b80925 commit cb4b1b6

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

lib/FrontendTool/FrontendTool.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,9 @@ class JSONFixitWriter : public DiagnosticConsumer {
595595
Info.ID == diag::function_type_no_parens.ID ||
596596
Info.ID == diag::convert_let_to_var.ID ||
597597
Info.ID == diag::parameter_extraneous_double_up.ID ||
598-
Info.ID == diag::attr_decl_attr_now_on_type.ID)
598+
Info.ID == diag::attr_decl_attr_now_on_type.ID ||
599+
Info.ID == diag::selector_construction_suggest.ID ||
600+
Info.ID == diag::selector_literal_deprecated_suggest.ID)
599601
return true;
600602
return false;
601603
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -disable-objc-attr-requires-foundation-module -parse %s -emit-fixits-path %t.remap
2+
// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %s.result
3+
import ObjectiveC
4+
5+
// REQUIRES: objc_interop
6+
7+
@objc class Selectors {
8+
func takeSel(_: Selector) {}
9+
func mySel() {}
10+
func test() {
11+
takeSel("mySel")
12+
takeSel(Selector("mySel"))
13+
}
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -disable-objc-attr-requires-foundation-module -parse %s -emit-fixits-path %t.remap
2+
// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %s.result
3+
import ObjectiveC
4+
5+
// REQUIRES: objc_interop
6+
7+
@objc class Selectors {
8+
func takeSel(_: Selector) {}
9+
func mySel() {}
10+
func test() {
11+
takeSel(#selector(Selectors.mySel))
12+
takeSel(#selector(Selectors.mySel))
13+
}
14+
}

0 commit comments

Comments
 (0)