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
// Fall back to Dictionary<K, V> if no context is otherwise available.
42
+
// Fall back to Swift.Dictionary<K, V> if no context is otherwise available.
43
43
vara=["Hello":1,"World":2]
44
44
vara2:Dictionary<String,Int>= a
45
45
vara3=["Hello":1]
@@ -52,20 +52,20 @@ var b3 = [1 : 2.5]
52
52
// <rdar://problem/22584076> QoI: Using array literal init with dictionary produces bogus error
53
53
54
54
// expected-note @+1 {{did you mean to use a dictionary literal instead?}}
55
-
var _:Dictionary<String,(Int)->Int>?=[ // expected-error {{dictionary of type 'Dictionary<String, (Int) -> Int>' cannot be initialized with array literal}}
55
+
var _:MyDictionary<String,(Int)->Int>?=[ // expected-error {{dictionary of type 'MyDictionary<String, (Int) -> Int>' cannot be initialized with array literal}}
56
56
"closure_1"asString,{(Int)->Intin0},
57
57
"closure_2",{(Int)->Intin0}]
58
58
59
59
60
-
var _:Dictionary<String,Int>?=["foo",1] // expected-error {{dictionary of type 'Dictionary<String, Int>' cannot be initialized with array literal}}
61
-
// expected-note @-1 {{did you mean to use a dictionary literal instead?}} {{41-42=:}}
60
+
var _:MyDictionary<String,Int>?=["foo",1] // expected-error {{dictionary of type 'MyDictionary<String, Int>' cannot be initialized with array literal}}
61
+
// expected-note @-1 {{did you mean to use a dictionary literal instead?}} {{43-44=:}}
62
62
63
-
var _:Dictionary<String,Int>?=["foo",1,"bar",42] // expected-error {{dictionary of type 'Dictionary<String, Int>' cannot be initialized with array literal}}
64
-
// expected-note @-1 {{did you mean to use a dictionary literal instead?}} {{41-42=:}} {{51-52=:}}
63
+
var _:MyDictionary<String,Int>?=["foo",1,"bar",42] // expected-error {{dictionary of type 'MyDictionary<String, Int>' cannot be initialized with array literal}}
64
+
// expected-note @-1 {{did you mean to use a dictionary literal instead?}} {{43-44=:}} {{53-54=:}}
65
65
66
-
var _:Dictionary<String,Int>?=["foo",1.0,2] // expected-error {{cannot convert value of type '[Any]' to specified type 'Dictionary<String, Int>?'}}
66
+
var _:MyDictionary<String,Int>?=["foo",1.0,2] // expected-error {{cannot convert value of type '[Any]' to specified type 'MyDictionary<String, Int>?'}}
67
67
68
-
var _:Dictionary<String,Int>?=["foo":1.0] // expected-error {{cannot convert value of type 'Double' to expected dictionary value type 'Int'}}
68
+
var _:MyDictionary<String,Int>?=["foo":1.0] // expected-error {{cannot convert value of type 'Double' to expected dictionary value type 'Int'}}
69
69
70
70
71
71
// <rdar://problem/24058895> QoI: Should handle [] in dictionary contexts better
@@ -78,33 +78,33 @@ class C : A { }
78
78
79
79
func testDefaultExistentials(){
80
80
let _ =["a":1,"b":2.5,"c":"hello"]
81
-
// expected-error@-1{{heterogeneous collection literal could only be inferred to 'Dictionary<String, Any>'; add explicit type annotation if this is intentional}}{{46-46= as Dictionary<String, Any>}}
81
+
// 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]}}
82
82
83
83
let _:[String:Any]=["a":1,"b":2.5,"c":"hello"]
84
84
85
85
let _ =["a":1,"b":nil,"c":"hello"]
86
-
// expected-error@-1{{heterogeneous collection literal could only be inferred to 'Dictionary<String, Any?>'; add explicit type annotation if this is intentional}}{{46-46= as Dictionary<String, Any?>}}
86
+
// 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?]}}
87
87
88
88
let _:[String:Any?]=["a":1,"b":nil,"c":"hello"]
89
89
90
90
letd2=[:]
91
91
// expected-error@-1{{empty collection literal requires an explicit type}}
92
92
93
-
let _:Int= d2 // expected-error{{value of type 'Dictionary<AnyHashable, Any>'}}
93
+
let _:Int= d2 // expected-error{{value of type '[AnyHashable : Any]'}}
94
94
95
95
let _ =["a":1,
96
96
"b":["a",2,3.14159],
97
97
"c":["a":2,"b":3.5]]
98
-
// expected-error@-3{{heterogeneous collection literal could only be inferred to 'Dictionary<String, Any>'; add explicit type annotation if this is intentional}}
98
+
// expected-error@-3{{heterogeneous collection literal could only be inferred to '[String : Any]'; add explicit type annotation if this is intentional}}
99
99
100
100
letd3=["b":B(),"c":C()]
101
-
let _:Int= d3 // expected-error{{value of type 'Dictionary<String, A>'}}
101
+
let _:Int= d3 // expected-error{{value of type '[String : A]'}}
102
102
103
103
let _ =["a":B(),17:"seventeen",3.14159:"Pi"]
104
-
// expected-error@-1{{heterogeneous collection literal could only be inferred to 'Dictionary<AnyHashable, Any>'}}
104
+
// expected-error@-1{{heterogeneous collection literal could only be inferred to '[AnyHashable : Any]'}}
105
105
106
106
let _ =["a":"hello",17:"string"]
107
-
// expected-error@-1{{heterogeneous collection literal could only be inferred to 'Dictionary<AnyHashable, String>'}}
107
+
// expected-error@-1{{heterogeneous collection literal could only be inferred to '[AnyHashable : String]'}}
108
108
}
109
109
110
110
// SR-4952, rdar://problem/32330004 - Assertion failure during swift::ASTVisitor<::FailureDiagnosis,...>::visit
0 commit comments