You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/decl/var/usage.swift
+12-1Lines changed: 12 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -330,6 +330,11 @@ func test(_ a : Int?, b : Any) {
330
330
iflet x = b as?Int{ // expected-warning {{value 'x' was defined but never used; consider replacing with boolean test}} {{6-14=}} {{16-19=is}}
331
331
}
332
332
333
+
// SR-14646. Special case, turn this into an 'is' test with optional value.
334
+
letbb:Any?=3
335
+
iflet bbb = bb as?Int{ // expected-warning {{value 'bbb' was defined but never used; consider replacing with boolean test}} {{6-16=}} {{19-22=is}}
336
+
}
337
+
333
338
// SR-1112
334
339
335
340
letxxx:Int?=0
@@ -356,7 +361,7 @@ let optionalString: String? = "check"
356
361
iflet string = optionalString {} // expected-warning {{value 'string' was defined but never used; consider replacing with boolean test}} {{4-17=}} {{31-31= != nil}}
357
362
358
363
letoptionalAny:Any?="check"
359
-
iflet string = optionalAny as?String{} // expected-warning {{value 'string' was defined but never used; consider replacing with boolean test}} {{4-17=(}} {{39-39=) != nil}}
364
+
iflet string = optionalAny as?String{} // expected-warning {{value 'string' was defined but never used; consider replacing with boolean test}} {{4-17=}} {{29-32=is}}
360
365
361
366
// Due to the complexities of global variable tracing, these will not generate warnings
iflet bar = foo as?Foo{return42} // expected-warning {{value 'bar' was defined but never used; consider replacing with boolean test}} {{6-16=}} {{20-23=is}}
0 commit comments