@@ -132,27 +132,31 @@ func warnOptionalToIUOAny(_ a: Int?, _ b: Any??, _ c: Int???, _ d: Any????) {
132
132
}
133
133
134
134
func takesCollectionOfAny( _ a: [ Any ] , _ d: [ String : Any ] ) { }
135
+ func takesCollectionOfOptionalAny( _ a: [ Any ? ] , _ d: [ String : Any ? ] ) { }
135
136
136
- func warnCollectionOfAny( _ a: [ Int ? ] , _ d: [ String : Int ? ] ) {
137
- // https://bugs.swift.org/browse/SR-2928 - Collection casts from collections of optionals to collections of Any need custom handling
138
- takesCollectionOfAny ( a, d) // expected-warning {{expression implicitly coerced from 'Int?' to 'Any'}}
139
- // expected-note@-1 {{provide a default value to avoid this warning}}{{25-25= ?? <#default value#>}}
140
- // expected-note@-2 {{force-unwrap the value to avoid this warning}}{{25-25=!}}
141
- // expected-note@-3 {{explicitly cast to 'Any' with 'as Any' to silence this warning}}{{25-25= as Any}}
142
- // expected-warning@-4 {{expression implicitly coerced from 'Int?' to 'Any'}}
143
- // expected-note@-5 {{provide a default value to avoid this warning}}{{28-28= ?? <#default value#>}}
144
- // expected-note@-6 {{force-unwrap the value to avoid this warning}}{{28-28=!}}
145
- // expected-note@-7 {{explicitly cast to 'Any' with 'as Any' to silence this warning}}{{28-28= as Any}}
146
-
147
- // https://bugs.swift.org/browse/SR-2928 - Collection casts from collections of optionals to collections of Any need custom handling
148
- takesCollectionOfAny ( a as [ Any ] , d as [ String : Any ] ) // expected-warning {{expression implicitly coerced from 'Int?' to 'Any'}}
149
- // expected-note@-1 {{provide a default value to avoid this warning}}{{25-25= ?? <#default value#>}}
150
- // expected-note@-2 {{force-unwrap the value to avoid this warning}}{{25-25=!}}
151
- // expected-note@-3 {{explicitly cast to 'Any' with 'as Any' to silence this warning}}{{25-25= as Any}}
152
- // expected-warning@-4 {{expression implicitly coerced from 'Int?' to 'Any'}}
153
- // expected-note@-5 {{provide a default value to avoid this warning}}{{37-37= ?? <#default value#>}}
154
- // expected-note@-6 {{force-unwrap the value to avoid this warning}}{{37-37=!}}
155
- // expected-note@-7 {{explicitly cast to 'Any' with 'as Any' to silence this warning}}{{37-37= as Any}}
137
+ func warnCollectionOfOptionalToAnyCoercion( _ a: [ Int ? ] , _ d: [ String : Int ? ] ) {
138
+ takesCollectionOfAny ( a, d) // expected-warning {{expression implicitly coerced from '[Int?]' to '[Any]'}}
139
+ // expected-note@-1 {{explicitly cast to '[Any]' with 'as [Any]' to silence this warning}}{{25-25= as [Any]}}
140
+ // expected-warning@-2 {{expression implicitly coerced from '[String : Int?]' to '[String : Any]'}}
141
+ // expected-note@-3 {{explicitly cast to '[String : Any]' with 'as [String : Any]' to silence this warning}}{{28-28= as [String : Any]}}
142
+
143
+ takesCollectionOfAny ( a as [ Any ] , d as [ String : Any ] )
144
+ }
145
+
146
+ func warnCollectionOfTripleOptionalToAnyCoercion( _ a: [ Any ? ? ? ] , _ d: [ String : Any ? ? ? ] ) {
147
+ takesCollectionOfAny ( a, d) // expected-warning {{expression implicitly coerced from '[Any???]' to '[Any]'}}
148
+ // expected-note@-1 {{explicitly cast to '[Any]' with 'as [Any]' to silence this warning}}{{25-25= as [Any]}}
149
+ // expected-warning@-2 {{expression implicitly coerced from '[String : Any???]' to '[String : Any]'}}
150
+ // expected-note@-3 {{explicitly cast to '[String : Any]' with 'as [String : Any]' to silence this warning}}{{28-28= as [String : Any]}}
151
+
152
+ takesCollectionOfAny ( a as [ Any ] , d as [ String : Any ] )
153
+
154
+ takesCollectionOfOptionalAny ( a, d) // expected-warning {{expression implicitly coerced from '[Any???]' to '[Any?]'}}
155
+ // expected-note@-1 {{explicitly cast to '[Any?]' with 'as [Any?]' to silence this warning}}{{33-33= as [Any?]}}
156
+ // expected-warning@-2 {{expression implicitly coerced from '[String : Any???]' to '[String : Any?]'}}
157
+ // expected-note@-3 {{explicitly cast to '[String : Any?]' with 'as [String : Any?]' to silence this warning}}{{36-36= as [String : Any?]}}
158
+
159
+ takesCollectionOfOptionalAny ( a as [ Any ? ] , d as [ String : Any ? ] )
156
160
}
157
161
158
162
func warnOptionalInStringInterpolationSegment( _ o : Int ? ) {
0 commit comments