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
+34-3Lines changed: 34 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -332,11 +332,42 @@ func test(_ a : Int?, b : Any) {
332
332
333
333
// SR-14646. Special case, turn this into an 'is' test with optional value.
334
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
-
}
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
+
iflet bbb =(bb)as?Int{} // expected-warning {{value 'bbb' was defined but never used; consider replacing with boolean test}} {{6-16=}} {{21-24=is}}
337
+
338
+
func aa()->Any?{return1}
339
+
iflet aaa =aa()as?Int{} // expected-warning {{value 'aaa' was defined but never used; consider replacing with boolean test}} {{6-16=}} {{21-24=is}}
340
+
iflet aaa =(aa())as?Int{} // expected-warning {{value 'aaa' was defined but never used; consider replacing with boolean test}} {{6-16=}} {{23-26=is}}
341
+
342
+
func bb()->Any{return1}
343
+
iflet aaa =aa()as?Int{} // expected-warning {{value 'aaa' was defined but never used; consider replacing with boolean test}} {{6-16=}} {{21-24=is}}
344
+
iflet aaa =(aa())as?Int{} // expected-warning {{value 'aaa' was defined but never used; consider replacing with boolean test}} {{6-16=}} {{23-26=is}}
337
345
338
-
// SR-1112
339
346
347
+
func throwingAA()throws->Any?{return1}
348
+
do{
349
+
iflet aaa =try!throwingAA()as?Int{} // expected-warning {{value 'aaa' was defined but never used; consider replacing with boolean test}} {{8-18=}} {{36-39=is}}
350
+
iflet aaa =(try!throwingAA())as?Int{} // expected-warning {{value 'aaa' was defined but never used; consider replacing with boolean test}} {{8-18=}} {{38-41=is}}
351
+
iflet aaa =trythrowingAA()as?Int{} // expected-warning {{value 'aaa' was defined but never used; consider replacing with boolean test}} {{8-18=}} {{35-38=is}}
352
+
iflet aaa =(trythrowingAA())as?Int{} // expected-warning {{value 'aaa' was defined but never used; consider replacing with boolean test}} {{8-18=}} {{37-40=is}}
353
+
}catch{}
354
+
iflet aaa =try?throwingAA()as?Int{} // expected-warning {{value 'aaa' was defined but never used; consider replacing with boolean test}} {{6-16=(}} {{41-41=) != nil}}
355
+
iflet aaa =(try?throwingAA())as?Int{} // expected-warning {{value 'aaa' was defined but never used; consider replacing with boolean test}} {{6-16=}} {{36-39=is}}
356
+
357
+
func throwingBB()throws->Any{return1}
358
+
do{
359
+
iflet bbb =try!throwingBB()as?Int{} // expected-warning {{value 'bbb' was defined but never used; consider replacing with boolean test}} {{8-18=}} {{36-39=is}}
360
+
iflet bbb =(try!throwingBB())as?Int{} // expected-warning {{value 'bbb' was defined but never used; consider replacing with boolean test}} {{8-18=}} {{38-41=is}}
361
+
iflet bbb =trythrowingBB()as?Int{} // expected-warning {{value 'bbb' was defined but never used; consider replacing with boolean test}} {{8-18=}} {{35-38=is}}
362
+
iflet bbb =(trythrowingBB())as?Int{} // expected-warning {{value 'bbb' was defined but never used; consider replacing with boolean test}} {{8-18=}} {{37-40=is}}
363
+
}catch{}
364
+
iflet bbb =try?throwingBB()as?Int{} // expected-warning {{value 'bbb' was defined but never used; consider replacing with boolean test}} {{6-16=(}} {{41-41=) != nil}}
365
+
iflet bbb =(try?throwingBB())as?Int{} // expected-warning {{value 'bbb' was defined but never used; consider replacing with boolean test}} {{6-16=}} {{36-39=is}}
366
+
367
+
letcc:(Any?,Any)=(1,2)
368
+
iflet(cc1, cc2)= cc as?(Int,Int){} // expected-warning {{immutable value 'cc1' was never used; consider replacing with '_' or removing it}} expected-warning {{immutable value 'cc2' was never used; consider replacing with '_' or removing it}}
0 commit comments