Skip to content

Commit 6b8ee42

Browse files
committed
[fixcode] Accept the fixit for adding bang to unwrap optional.
This is useful for getting fixits for the IOU handling changes.
1 parent 273ad53 commit 6b8ee42

File tree

3 files changed

+3
-8
lines changed

3 files changed

+3
-8
lines changed

lib/FrontendTool/FrontendTool.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -554,11 +554,6 @@ class JSONFixitWriter : public DiagnosticConsumer {
554554
if (FixitAll)
555555
return true;
556556

557-
// Err on the side of caution and don't automatically add bang, which may
558-
// lead to crashes.
559-
if (Info.ID == diag::missing_unwrap_optional.ID)
560-
return false;
561-
562557
// Do not add a semi as it is wrong in most cases during migration
563558
if (Info.ID == diag::statement_same_line_without_semi.ID)
564559
return false;

test/FixCode/fixits-apply.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ b as Derived
1111
b as! Base
1212

1313
var opti : Int?
14-
// Don't add bang.
14+
// Add bang.
1515
var i : Int = opti
1616
// But remove unnecessary bang.
1717
var i2 : Int = i!

test/FixCode/fixits-apply.swift.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ b as! Derived
1111
b
1212

1313
var opti : Int?
14-
// Don't add bang.
15-
var i : Int = opti
14+
// Add bang.
15+
var i : Int = opti!
1616
// But remove unnecessary bang.
1717
var i2 : Int = i
1818

0 commit comments

Comments
 (0)