@@ -7,61 +7,54 @@ func takeAny(_ left: Any, _ right: Any) -> Int? {
77func throwing( ) throws -> Int ? { }
88
99func warnOptionalToAnyCoercion( value x: Int ? ) -> Any {
10- let a : Any = x // expected-warning {{expression implicitly coerced from 'Optional< Int> ' to Any}}
11- // expected-note@-1 {{provide a default value to avoid the warning}}
12- // expected-note@-2 {{force-unwrap the value to avoid the warning}}
13- // expected-note@-3 {{explicitly cast to Any with 'as Any' to silence}}
10+ let a : Any = x // expected-warning {{expression implicitly coerced from 'Int? ' to Any}}
11+ // expected-note@-1 {{provide a default value to avoid this warning}}
12+ // expected-note@-2 {{force-unwrap the value to avoid this warning}}
13+ // expected-note@-3 {{explicitly cast to Any with 'as Any' to silence this warning }}
1414
1515 let b : Any = x as Any
1616
17- let c : Any = takeAny ( a, b) // expected-warning {{expression implicitly coerced from 'Optional< Int> ' to Any}}
18- // expected-note@-1 {{provide a default value to avoid the warning}}
19- // expected-note@-2 {{force-unwrap the value to avoid the warning}}
20- // expected-note@-3 {{explicitly cast to Any with 'as Any' to silence}}
17+ let c : Any = takeAny ( a, b) // expected-warning {{expression implicitly coerced from 'Int? ' to Any}}
18+ // expected-note@-1 {{provide a default value to avoid this warning}}
19+ // expected-note@-2 {{force-unwrap the value to avoid this warning}}
20+ // expected-note@-3 {{explicitly cast to Any with 'as Any' to silence this warning }}
2121
22- let d : Any = takeAny ( c, c) as Any
22+ let _ : Any = takeAny ( c, c) as Any
2323
24- let e : Any = ( x) // expected-warning {{expression implicitly coerced from 'Optional<Int>' to Any}}
25- // expected-note@-1 {{provide a default value to avoid the warning}}
26- // expected-note@-2 {{force-unwrap the value to avoid the warning}}
27- // expected-note@-3 {{explicitly cast to Any with 'as Any' to silence}}
28-
29- _ = takeAny ( d, e)
24+ let _: Any = ( x) // expected-warning {{expression implicitly coerced from 'Int?' to Any}}
25+ // expected-note@-1 {{provide a default value to avoid this warning}}
26+ // expected-note@-2 {{force-unwrap the value to avoid this warning}}
27+ // expected-note@-3 {{explicitly cast to Any with 'as Any' to silence this warning}}
3028
3129 let f : Any = ( x as Any )
3230 let g : Any = ( x) as ( Any )
3331
34- _ = takeAny ( f as? Int , g) // expected-warning {{expression implicitly coerced from 'Optional<Int>' to Any}}
35- // expected-note@-1 {{provide a default value to avoid the warning}}
36- // expected-note@-2 {{force-unwrap the value to avoid the warning}}
37- // expected-note@-3 {{explicitly cast to Any with 'as Any' to silence}}
38-
39- let h : Any = takeAny ( f as? Int , g) as Any // expected-warning {{expression implicitly coerced from 'Optional<Int>' to Any}}
40- // expected-note@-1 {{provide a default value to avoid the warning}}
41- // expected-note@-2 {{force-unwrap the value to avoid the warning}}
42- // expected-note@-3 {{explicitly cast to Any with 'as Any' to silence}}
32+ _ = takeAny ( f as? Int , g) // expected-warning {{expression implicitly coerced from 'Int?' to Any}}
33+ // expected-note@-1 {{provide a default value to avoid this warning}}
34+ // expected-note@-2 {{force-unwrap the value to avoid this warning}}
35+ // expected-note@-3 {{explicitly cast to Any with 'as Any' to silence this warning}}
4336
44- let i : Any = takeAny ( f as? Int as Any , g) as Any
37+ let _: Any = takeAny ( f as? Int , g) as Any // expected-warning {{expression implicitly coerced from 'Int?' to Any}}
38+ // expected-note@-1 {{provide a default value to avoid this warning}}
39+ // expected-note@-2 {{force-unwrap the value to avoid this warning}}
40+ // expected-note@-3 {{explicitly cast to Any with 'as Any' to silence this warning}}
4541
46- _ = takeAny ( h , i )
42+ let _ : Any = takeAny ( f as? Int as Any , g ) as Any
4743
48- let j : Any = x! == x! ? 1 : x // expected-warning {{expression implicitly coerced from 'Optional< Int> ' to Any}}
49- // expected-note@-1 {{provide a default value to avoid the warning}}
50- // expected-note@-2 {{force-unwrap the value to avoid the warning}}
51- // expected-note@-3 {{explicitly cast to Any with 'as Any' to silence}}
44+ let _ : Any = x! == x! ? 1 : x // expected-warning {{expression implicitly coerced from 'Int? ' to Any}}
45+ // expected-note@-1 {{provide a default value to avoid this warning}}
46+ // expected-note@-2 {{force-unwrap the value to avoid this warning}}
47+ // expected-note@-3 {{explicitly cast to Any with 'as Any' to silence this warning }}
5248
53- let k : Any
5449 do {
55- k = try throwing ( ) // expected-warning {{expression implicitly coerced from 'Optional< Int> ' to Any}}
56- // expected-note@-1 {{provide a default value to avoid the warning}}
57- // expected-note@-2 {{force-unwrap the value to avoid the warning}}
58- // expected-note@-3 {{explicitly cast to Any with 'as Any' to silence}}
50+ let _ : Any = try throwing ( ) // expected-warning {{expression implicitly coerced from 'Int? ' to Any}}
51+ // expected-note@-1 {{provide a default value to avoid this warning}}
52+ // expected-note@-2 {{force-unwrap the value to avoid this warning}}
53+ // expected-note@-3 {{explicitly cast to Any with 'as Any' to silence this warning }}
5954 } catch { }
6055
61- _ = takeAny ( j, k)
62-
63- return x // expected-warning {{expression implicitly coerced from 'Optional<Int>' to Any}}
64- // expected-note@-1 {{provide a default value to avoid the warning}}
65- // expected-note@-2 {{force-unwrap the value to avoid the warning}}
66- // expected-note@-3 {{explicitly cast to Any with 'as Any' to silence}}
56+ return x // expected-warning {{expression implicitly coerced from 'Int?' to Any}}
57+ // expected-note@-1 {{provide a default value to avoid this warning}}
58+ // expected-note@-2 {{force-unwrap the value to avoid this warning}}
59+ // expected-note@-3 {{explicitly cast to Any with 'as Any' to silence this warning}}
6760}
0 commit comments