mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[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:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
14
test/FixCode/fixits-apply-selector.swift
Normal file
14
test/FixCode/fixits-apply-selector.swift
Normal 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"))
|
||||||
|
}
|
||||||
|
}
|
||||||
14
test/FixCode/fixits-apply-selector.swift.result
Normal file
14
test/FixCode/fixits-apply-selector.swift.result
Normal 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))
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user