@@ -7,61 +7,54 @@ func takeAny(_ left: Any, _ right: Any) -> Int? {
7
7
func throwing( ) throws -> Int ? { }
8
8
9
9
func 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 }}
14
14
15
15
let b : Any = x as Any
16
16
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 }}
21
21
22
- let d : Any = takeAny ( c, c) as Any
22
+ let _ : Any = takeAny ( c, c) as Any
23
23
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}}
30
28
31
29
let f : Any = ( x as Any )
32
30
let g : Any = ( x) as ( Any )
33
31
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}}
43
36
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}}
45
41
46
- _ = takeAny ( h , i )
42
+ let _ : Any = takeAny ( f as? Int as Any , g ) as Any
47
43
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 }}
52
48
53
- let k : Any
54
49
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 }}
59
54
} catch { }
60
55
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}}
67
60
}
0 commit comments