Skip to content

Commit 7a3c666

Browse files
benlangmuirtkremenek
authored andcommitted
[FixCode] Pick up fixit for let->var change (#2848)
This is an important fixit, but was lost because it is on the note instead of the error. rdar://problem/26593117
1 parent ec3a34c commit 7a3c666

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

lib/FrontendTool/FrontendTool.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,7 @@ class JSONFixitWriter : public DiagnosticConsumer {
575575
Info.ID == diag::forced_downcast_noop.ID ||
576576
Info.ID == diag::variable_never_mutated.ID ||
577577
Info.ID == diag::function_type_no_parens.ID ||
578+
Info.ID == diag::convert_let_to_var.ID ||
578579
Info.ID == diag::parameter_extraneous_double_up.ID)
579580
return true;
580581
return false;

test/FixCode/fixits-apply.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,13 @@ func ftest3(_ fd: CInt) {
112112
func ftest4(_ fd: UInt) {
113113
recit(fd)
114114
}
115+
116+
func letToVar1() {
117+
let x = 1
118+
if x == 2 {
119+
x += 3
120+
}
121+
let y = ""
122+
y.append("as")
123+
y.append("df")
124+
}

test/FixCode/fixits-apply.swift.result

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,13 @@ func ftest3(_ fd: CInt) {
115115
func ftest4(_ fd: UInt) {
116116
recit(Int32(fd))
117117
}
118+
119+
func letToVar1() {
120+
var x = 1
121+
if x == 2 {
122+
x += 3
123+
}
124+
var y = ""
125+
y.append("as")
126+
y.append("df")
127+
}

0 commit comments

Comments
 (0)