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-warning@-1{{heterogeneous collection literal could only be inferred to '[Any?]'; add explicit type annotation if this is intentional}}
161
163
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}}
163
164
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}}
165
165
166
166
leta6=[B(),C()]
167
167
let _:Int= a6 // expected-error{{value of type '[A]'}}
168
168
169
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
170
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
171
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
172
let _ =true?[]:[]
179
-
// expected-warning@-1{{empty collection literal requires an explicit type}}
180
173
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
174
185
175
func f2<T>(_:[T]){}
186
176
187
177
func f3<T>()->[T]?{}
188
178
189
179
f2([])
190
-
// expected-warning@-1{{empty collection literal requires an explicit type}}
191
180
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
181
_ =f3()??[]
194
-
// expected-warning@-1{{empty collection literal requires an explicit type}}
Copy file name to clipboardExpand all lines: test/Constraints/dictionary_literal.swift
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -120,6 +120,8 @@ class B : A { }
120
120
classC:A{}
121
121
122
122
func testDefaultExistentials(){
123
+
let _ =["a":["b":["c":["d",1,true]]]]
124
+
123
125
let _ =["a":1,"b":2.5,"c":"hello"]
124
126
// expected-error@-1{{heterogeneous collection literal could only be inferred to '[String : Any]'; add explicit type annotation if this is intentional}}{{46-46= as [String : Any]}}
// 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}}
143
144
144
145
letd3=["b":B(),"c":C()]
145
146
let _:Int= d3 // expected-error{{value of type '[String : A]'}}
// expected-warning@-1{{heterogeneous collection literal could only be inferred to '[String : AnyObject]'; add explicit type annotation if this is intentiona}}
11
10
_ =["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}}
13
11
_ =[["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}}
15
12
_ =[["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