Skip to content

Commit 146be88

Browse files
committed
[FixCode] When picking-up fixits for migration ignore the fixits for adding @objc(selector).
These interact badly with the swift migrator, they are triggered by label mismatches in pre-migrated code. We also don't generally need them since we do inference for the most common cases.
1 parent 48a063e commit 146be88

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

lib/FrontendTool/FrontendTool.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,11 @@ class JSONFixitWriter : public DiagnosticConsumer {
563563
Info.ID == diag::missing_argument_labels.ID ||
564564
Info.ID == diag::override_argument_name_mismatch.ID)
565565
return false;
566+
// This also interacts badly with the swift migrator, it unnecessary adds
567+
// @objc(selector) attributes triggered by the mismatched label changes.
568+
if (Info.ID == diag::objc_witness_selector_mismatch.ID ||
569+
Info.ID == diag::witness_non_objc.ID)
570+
return false;
566571

567572
if (Kind == DiagnosticKind::Error)
568573
return true;

test/FixCode/fixits-apply.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,18 @@ func ftest2(x x: Int -> Int) {}
8080
protocol SomeProt {
8181
func protMeth(p: Int)
8282
}
83-
class Test2 : SomeProt {
83+
@objc protocol SomeObjCProt {
84+
func objcprotMeth(p: Int)
85+
}
86+
class Test2 : SomeProt, SomeObjCProt {
8487
func protMeth(_ p: Int) {}
8588

8689
func instMeth(p: Int) {}
8790
func instMeth2(p: Int, p2: Int) {}
91+
func objcprotMeth(_ p: Int) {}
92+
}
93+
@objc class Test3 : SomeObjCProt {
94+
func objcprotMeth(_ p: Int) {}
8895
}
8996
class SubTest2 : Test2 {
9097
override func instMeth(_ p: Int) {}

test/FixCode/fixits-apply.swift.result

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,18 @@ func ftest2(x: (Int) -> Int) {}
8383
protocol SomeProt {
8484
func protMeth(p: Int)
8585
}
86-
class Test2 : SomeProt {
86+
@objc protocol SomeObjCProt {
87+
func objcprotMeth(p: Int)
88+
}
89+
class Test2 : SomeProt, SomeObjCProt {
8790
func protMeth(_ p: Int) {}
8891

8992
func instMeth(p: Int) {}
9093
func instMeth2(p: Int, p2: Int) {}
94+
func objcprotMeth(_ p: Int) {}
95+
}
96+
@objc class Test3 : SomeObjCProt {
97+
func objcprotMeth(_ p: Int) {}
9198
}
9299
class SubTest2 : Test2 {
93100
override func instMeth(_ p: Int) {}

0 commit comments

Comments
 (0)