Skip to content

Commit 338f402

Browse files
committed
[FixCode] Avoid removing @ib* attributes
If there are type-checking issues, these interact poorly with the migrator and may remove @ib* attributes unnecessarily. rdar://problem/26886636
1 parent e43c058 commit 338f402

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

lib/FrontendTool/FrontendTool.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,17 @@ class JSONFixitWriter : public DiagnosticConsumer {
569569
if (Info.ID == diag::objc_witness_selector_mismatch.ID ||
570570
Info.ID == diag::witness_non_objc.ID)
571571
return false;
572+
// The following interact badly with the swift migrator by removing @IB*
573+
// attributes when there is some unrelated type issue.
574+
if (Info.ID == diag::invalid_iboutlet.ID ||
575+
Info.ID == diag::iboutlet_nonobjc_class.ID ||
576+
Info.ID == diag::iboutlet_nonobjc_protocol.ID ||
577+
Info.ID == diag::iboutlet_nonobject_type.ID ||
578+
Info.ID == diag::iboutlet_only_mutable.ID ||
579+
Info.ID == diag::invalid_ibdesignable_extension.ID ||
580+
Info.ID == diag::invalid_ibinspectable.ID ||
581+
Info.ID == diag::invalid_ibaction_decl.ID)
582+
return false;
572583

573584
if (Kind == DiagnosticKind::Error)
574585
return true;

test/FixCode/fixits-apply.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,18 @@ func evilCommas(s: String) {
180180

181181
import Empty
182182
func testGenericSig(x: Empty<Int>) -> Empty<String> {}
183+
184+
class NonObjC {}
185+
protocol NonObjCProtocol {}
186+
@objc class IBIssues {
187+
@IBOutlet static private var ibout1: IBIssues!
188+
@IBOutlet private var ibout2: NonObjC!
189+
@IBOutlet private var ibout3: NonObjCProtocol!
190+
@IBOutlet private let ibout4: IBIssues!
191+
@IBOutlet private var ibout5: [[IBIssues]]!
192+
@IBOutlet private var ibout6: [String:String]!
193+
@IBInspectable static private var ibinspect1: IBIssues!
194+
@IBAction static func ibact() {}
195+
}
196+
197+
@IBDesignable extension SomeProt {}

test/FixCode/fixits-apply.swift.result

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,3 +183,18 @@ func evilCommas(s: String) {
183183

184184
import Empty
185185
func testGenericSig(x: Empty<Int>) -> Empty<String> {}
186+
187+
class NonObjC {}
188+
protocol NonObjCProtocol {}
189+
@objc class IBIssues {
190+
@IBOutlet static private var ibout1: IBIssues!
191+
@IBOutlet private var ibout2: NonObjC!
192+
@IBOutlet private var ibout3: NonObjCProtocol!
193+
@IBOutlet private let ibout4: IBIssues!
194+
@IBOutlet private var ibout5: [[IBIssues]]!
195+
@IBOutlet private var ibout6: [String:String]!
196+
@IBInspectable static private var ibinspect1: IBIssues!
197+
@IBAction static func ibact() {}
198+
}
199+
200+
@IBDesignable extension SomeProt {}

0 commit comments

Comments
 (0)