@@ -16,6 +16,13 @@ class C {
16
16
// expected-note@-1 {{provide a default value to avoid this warning}}{{40-40= ?? <#default value#>}}
17
17
// expected-note@-2 {{force-unwrap the value to avoid this warning}}{{40-40=!}}
18
18
// expected-note@-3 {{explicitly cast to 'Any' with 'as Any' to silence this warning}}{{40-40= as Any}}
19
+
20
+ subscript( i: Int ) -> Int ! { return 0 }
21
+ subscript( i: Float ) -> Any ! { return 0 }
22
+ }
23
+
24
+ class D {
25
+ init !( ) { }
19
26
}
20
27
21
28
func returningIUO( ) -> Int ! { return 1 }
@@ -43,6 +50,22 @@ func warnIUOToAnyCoercion(_ a: Int!, _ b: Any?!) {
43
50
// expected-warning@-4 {{expression implicitly coerced from 'Any??' to 'Any'}}
44
51
// expected-note@-5 {{force-unwrap the value to avoid this warning}}{{27-27=!!}}
45
52
// expected-note@-6 {{explicitly cast to 'Any' with 'as Any' to silence this warning}}{{27-27= as Any}}
53
+ _ = takeAny ( C ( ) [ 0 ] , C ( ) [ 1.0 ] ) // expected-warning {{expression implicitly coerced from 'Int?' to 'Any'}}
54
+ // expected-note@-1 {{provide a default value to avoid this warning}}{{21-21= ?? <#default value#>}}
55
+ // expected-note@-2 {{force-unwrap the value to avoid this warning}}{{21-21=!}}
56
+ // expected-note@-3 {{explicitly cast to 'Any' with 'as Any' to silence this warning}}{{21-21= as Any}}
57
+ // expected-warning@-4 {{expression implicitly coerced from 'Any?' to 'Any'}}
58
+ // expected-note@-5 {{provide a default value to avoid this warning}}{{31-31= ?? <#default value#>}}
59
+ // expected-note@-6 {{force-unwrap the value to avoid this warning}}{{31-31=!}}
60
+ // expected-note@-7 {{explicitly cast to 'Any' with 'as Any' to silence this warning}}{{31-31= as Any}}
61
+ _ = takeAny ( D ( ) , D ( ) ) // expected-warning {{expression implicitly coerced from 'D?' to 'Any'}}
62
+ // expected-note@-1 {{provide a default value to avoid this warning}}{{18-18= ?? <#default value#>}}
63
+ // expected-note@-2 {{force-unwrap the value to avoid this warning}}{{18-18=!}}
64
+ // expected-note@-3 {{explicitly cast to 'Any' with 'as Any' to silence this warning}}{{18-18= as Any}}
65
+ // expected-warning@-4 {{expression implicitly coerced from 'D?' to 'Any'}}
66
+ // expected-note@-5 {{provide a default value to avoid this warning}}{{23-23= ?? <#default value#>}}
67
+ // expected-note@-6 {{force-unwrap the value to avoid this warning}}{{23-23=!}}
68
+ // expected-note@-7 {{explicitly cast to 'Any' with 'as Any' to silence this warning}}{{23-23= as Any}}
46
69
47
70
_ = takeAny ( a as Any , b as Any )
48
71
}
0 commit comments