Skip to content

Commit 2fc6e6f

Browse files
akyrtzitkremenek
authored andcommitted
Ignore fixits for adding objc(selector) when doing migration, and fixits for mismatch label in overridden method (#2734)
* [FixCode] Follow-up for b4a2b53, ignore another diagnostic fixit that is messing with argument labels. * [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 634eb63 commit 2fc6e6f

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

lib/FrontendTool/FrontendTool.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,13 @@ class JSONFixitWriter : public DiagnosticConsumer {
560560
// The following interact badly with the swift migrator, they are undoing
561561
// migration of arguments to preserve the no-label for first argument.
562562
if (Info.ID == diag::witness_argument_name_mismatch.ID ||
563-
Info.ID == diag::missing_argument_labels.ID)
563+
Info.ID == diag::missing_argument_labels.ID ||
564+
Info.ID == diag::override_argument_name_mismatch.ID)
565+
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)
564570
return false;
565571

566572
if (Kind == DiagnosticKind::Error)

test/FixCode/fixits-apply.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,21 @@ 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) {}
95+
}
96+
class SubTest2 : Test2 {
97+
override func instMeth(_ p: Int) {}
8898
}
8999
Test2().instMeth(0)
90100
Test2().instMeth2(0, p2:1)

test/FixCode/fixits-apply.swift.result

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,21 @@ 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) {}
98+
}
99+
class SubTest2 : Test2 {
100+
override func instMeth(_ p: Int) {}
91101
}
92102
Test2().instMeth(0)
93103
Test2().instMeth2(0, p2:1)

0 commit comments

Comments
 (0)