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
// expected-error@-1{{empty collection literal requires an explicit type}}
143
143
let _:Int= a5 // expected-error{{value of type '[Any]'}}
144
144
145
+
let _:[Any]=[]
145
146
let _:[Any]=[1,"a",3.5]
146
147
let _:[Any]=[1,"a",[3.5,3.7,3.9]]
147
148
let _:[Any]=[1,"a",[3.5,"b",3]]
149
+
// expected-warning@-1{{heterogeneous collection literal could only be inferred to '[Any]'; add explicit type annotation if this is intentional}}
148
150
let _:[Any]=[1,[2,[3]]]
151
+
// expected-warning@-1{{heterogeneous collection literal could only be inferred to '[Any]'; add explicit type annotation if this is intentional}}
152
+
153
+
func f1()->[Any]{
154
+
[]
155
+
}
149
156
150
157
let _:[Any?]=[1,"a",nil,3.5]
151
158
let _:[Any?]=[1,"a",nil,[3.5,3.7,3.9]]
152
159
let _:[Any?]=[1,"a",nil,[3.5,"b",nil]]
160
+
// expected-warning@-1{{heterogeneous collection literal could only be inferred to '[Any?]'; add explicit type annotation if this is intentional}}
153
161
let _:[Any?]=[1,[2,[3]]]
162
+
// expected-warning@-1{{heterogeneous collection literal could only be inferred to '[Any]'; add explicit type annotation if this is intentional}}
154
163
let _:[Any?]=[1,nil,[2,nil,[3]]]
164
+
// expected-warning@-1{{heterogeneous collection literal could only be inferred to '[Any?]'; add explicit type annotation if this is intentional}}
155
165
156
166
leta6=[B(),C()]
157
167
let _:Int= a6 // expected-error{{value of type '[A]'}}
168
+
169
+
leta7:someCollection=[1,"Swift"]
170
+
// expected-warning@-1{{heterogeneous collection literal could only be inferred to '[Any]'; add explicit type annotation if this is intentional}} {{41-41= as [Any]}}
171
+
let _:(anySequence)?=[1,"Swift"]
172
+
// expected-warning@-1{{heterogeneous collection literal could only be inferred to '[Any]'; add explicit type annotation if this is intentional}}
173
+
let _:anySequence=[1,nil,"Swift"]
174
+
// expected-warning@-1{{heterogeneous collection literal could only be inferred to '[Any?]'; add explicit type annotation if this is intentional}}
175
+
let _ =[1,true,([],1)]
176
+
// expected-error@-1 {{heterogeneous collection literal could only be inferred to '[Any]'; add explicit type annotation if this is intentional}}
177
+
// expected-warning@-2 {{empty collection literal requires an explicit type}}
178
+
let _ =true?[]:[]
179
+
// expected-warning@-1{{empty collection literal requires an explicit type}}
180
+
let _ =(true,([1,"Swift"]))
181
+
//expected-warning@-1{{heterogeneous collection literal could only be inferred to '[Any]'; add explicit type annotation if this is intentional}}
182
+
let _ =([1,true])
183
+
//expected-error@-1{{heterogeneous collection literal could only be inferred to '[Any]'; add explicit type annotation if this is intentional}}
184
+
185
+
func f2<T>(_:[T]){}
186
+
187
+
func f3<T>()->[T]?{}
188
+
189
+
f2([])
190
+
// expected-warning@-1{{empty collection literal requires an explicit type}}
191
+
f2([1,nil,""])
192
+
// expected-warning@-1{{heterogeneous collection literal could only be inferred to '[Any?]'; add explicit type annotation if this is intentional}}
193
+
_ =f3()??[]
194
+
// expected-warning@-1{{empty collection literal requires an explicit type}}
// expected-error@-3{{heterogeneous collection literal could only be inferred to '[String : Any]'; add explicit type annotation if this is intentional}}
142
+
// expected-warning@-3{{heterogeneous collection literal could only be inferred to '[Any]'; add explicit type annotation if this is intentional}}
142
143
143
144
letd3=["b":B(),"c":C()]
144
145
let _:Int= d3 // expected-error{{value of type '[String : A]'}}
@@ -193,4 +194,4 @@ f59215(["", ""]) //expected-error{{dictionary of type '[String : String]' cannot
193
194
f59215(["","","",""]) //expected-error{{dictionary of type '[String : String]' cannot be used with array literal}}
194
195
// expected-note@-1{{did you mean to use a dictionary literal instead?}} {{11-12=:}} {{19-20=:}}
195
196
f59215(["","","",""]) //expected-error{{dictionary of type '[String : String]' cannot be used with array literal}}
196
-
// expected-note@-1{{did you mean to use a dictionary literal instead?}} {{11-12=:}} {{19-20=:}}
197
+
// expected-note@-1{{did you mean to use a dictionary literal instead?}} {{11-12=:}} {{19-20=:}}
// expected-warning@-1{{heterogeneous collection literal could only be inferred to '[String : AnyObject]'; add explicit type annotation if this is intentiona}}
10
11
_ =["x":["z",1]]as[String:[AnyObject]]
12
+
// expected-warning@-1{{heterogeneous collection literal could only be inferred to '[AnyObject]'; add explicit type annotation if this is intentional}}
11
13
_ =[["y":"z","a":1]]as[[String:AnyObject]]
14
+
// expected-warning@-1{{heterogeneous collection literal could only be inferred to '[String : AnyObject]'; add explicit type annotation if this is intentional}}
12
15
_ =[["z",1]]as[[AnyObject]]
16
+
// expected-warning@-1{{heterogeneous collection literal could only be inferred to '[AnyObject]'; add explicit type annotation if this is intentional}}
0 commit comments