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
[Diagnostics] Improve diagnostics related to pointer initialization
- Increase impact of a generic pointer-to-pointer mismatch fix to
match that of a contextual type failure. This allows more specific
fixes to take precedence.
- De-prioritize generic argument mismatch fix when both types are
pointers. This allows pointer-to-pointer conversion produce a
more specific fix.
- De-prioritize fixes that involve `Builtin.RawPointer` or `OpaquePointer`
in parameter positions. This helps to produce better diagnostics
for argument mismatches during pointer initialization e.g.
`UnsafeRawPointer(<pointer>)`.
// expected-error@-1 {{no exact matches in call to initializer}}
137
137
// expected-note@-2 {{candidate expects value of type 'UnsafeRawPointer' for parameter #1}}
138
138
// expected-note@-3 {{candidate expects value of type 'UnsafeMutableRawPointer' for parameter #1}}
139
-
// expected-note@-4 {{candidate expects value of type 'OpaquePointer' for parameter #1}}
140
-
// expected-note@-5 {{candidate expects value of type 'Builtin.RawPointer' for parameter #1}}
141
139
142
140
UnsafeRawPointer($0)asUnsafeBufferPointer<UInt16> // expected-error {{cannot convert value of type 'UnsafeRawPointer' to type 'UnsafeBufferPointer<UInt16>' in coercion}}
143
141
// expected-error@-1 {{no exact matches in call to initializer}}
144
142
// expected-note@-2 {{found candidate with type '(UnsafeRawPointer) -> UnsafeRawPointer'}}
145
-
// expected-note@-3 {{found candidate with type '(Builtin.RawPointer) -> UnsafeRawPointer'}}
146
-
// expected-note@-4 {{found candidate with type '(OpaquePointer) -> UnsafeRawPointer'}}
147
-
// expected-note@-5 {{found candidate with type '(UnsafeMutableRawPointer) -> UnsafeRawPointer'}}
143
+
// expected-note@-3 {{found candidate with type '(UnsafeMutableRawPointer) -> UnsafeRawPointer'}}
148
144
}
149
145
150
146
func SR12689_1(_ u:Int)->String{""} // expected-note {{found this candidate}} expected-note {{candidate expects value of type 'Int' for parameter #1 (got 'Double')}}
_ =UnsafeMutablePointer<Void>(rp) // expected-error {{no exact matches in call to initializer}} expected-warning {{UnsafeMutablePointer<Void> has been replaced by UnsafeMutableRawPointer}}
65
-
_ =UnsafeMutablePointer<Void>(mrp) // expected-error {{no exact matches in call to initializer}} expected-warning {{UnsafeMutablePointer<Void> has been replaced by UnsafeMutableRawPointer}}
64
+
_ =UnsafeMutablePointer<Void>(rp) // expected-error {{cannot convert value of type 'UnsafeRawPointer' to expected argument type 'UnsafeMutablePointer<Void>'}} expected-warning {{UnsafeMutablePointer<Void> has been replaced by UnsafeMutableRawPointer}}
65
+
_ =UnsafeMutablePointer<Void>(mrp) // expected-error {{cannot convert value of type 'UnsafeMutableRawPointer' to expected argument type 'UnsafeMutablePointer<Void>'}} expected-warning {{UnsafeMutablePointer<Void> has been replaced by UnsafeMutableRawPointer}}
66
66
_ =UnsafeMutablePointer<Void>(umpv) // expected-warning {{UnsafeMutablePointer<Void> has been replaced by UnsafeMutableRawPointer}}
67
67
_ =UnsafeMutablePointer<Void>(umpi) // expected-warning {{UnsafeMutablePointer<Void> has been replaced by UnsafeMutableRawPointer}}
68
68
_ =UnsafeMutablePointer<Void>(umps) // expected-warning {{UnsafeMutablePointer<Void> has been replaced by UnsafeMutableRawPointer}}
69
69
70
-
_ =UnsafePointer<Void>(rp) // expected-error {{no exact matches in call to initializer}} expected-warning {{UnsafePointer<Void> has been replaced by UnsafeRawPointer}}
71
-
_ =UnsafePointer<Void>(mrp) // expected-error {{no exact matches in call to initializer}} expected-warning {{UnsafePointer<Void> has been replaced by UnsafeRawPointer}}
70
+
_ =UnsafePointer<Void>(rp) // expected-error {{cannot convert value of type 'UnsafeRawPointer' to expected argument type 'UnsafePointer<Void>'}} expected-warning {{UnsafePointer<Void> has been replaced by UnsafeRawPointer}}
71
+
_ =UnsafePointer<Void>(mrp) // expected-error {{cannot convert value of type 'UnsafeMutableRawPointer' to expected argument type 'UnsafePointer<Void>'}} expected-warning {{UnsafePointer<Void> has been replaced by UnsafeRawPointer}}
72
72
_ =UnsafePointer<Void>(umpv) // expected-warning {{UnsafePointer<Void> has been replaced by UnsafeRawPointer}}
73
73
_ =UnsafePointer<Void>(upv) // expected-warning {{UnsafePointer<Void> has been replaced by UnsafeRawPointer}}
74
74
_ =UnsafePointer<Void>(umpi) // expected-warning {{UnsafePointer<Void> has been replaced by UnsafeRawPointer}}
75
75
_ =UnsafePointer<Void>(upi) // expected-warning {{UnsafePointer<Void> has been replaced by UnsafeRawPointer}}
76
76
_ =UnsafePointer<Void>(umps) // expected-warning {{UnsafePointer<Void> has been replaced by UnsafeRawPointer}}
77
77
_ =UnsafePointer<Void>(ups) // expected-warning {{UnsafePointer<Void> has been replaced by UnsafeRawPointer}}
78
78
79
-
_ =UnsafeMutablePointer<Int>(rp) // expected-error {{no exact matches in call to initializer}}
80
-
_ =UnsafeMutablePointer<Int>(mrp) // expected-error {{no exact matches in call to initializer}}
81
-
_ =UnsafeMutablePointer<Int>(orp) // expected-error {{no exact matches in call to initializer}}
82
-
_ =UnsafeMutablePointer<Int>(omrp) // expected-error {{no exact matches in call to initializer}}
79
+
_ =UnsafeMutablePointer<Int>(rp) // expected-error {{cannot convert value of type 'UnsafeRawPointer' to expected argument type 'UnsafeMutablePointer<Int>'}}
80
+
_ =UnsafeMutablePointer<Int>(mrp) // expected-error {{cannot convert value of type 'UnsafeMutableRawPointer' to expected argument type 'UnsafeMutablePointer<Int>'}}
81
+
_ =UnsafeMutablePointer<Int>(orp) // expected-error {{cannot convert value of type 'UnsafeRawPointer?' to expected argument type 'UnsafeMutablePointer<Int>'}}
82
+
_ =UnsafeMutablePointer<Int>(omrp) // expected-error {{cannot convert value of type 'UnsafeMutableRawPointer?' to expected argument type 'UnsafeMutablePointer<Int>'}}
83
83
84
-
_ =UnsafePointer<Int>(rp) // expected-error {{no exact matches in call to initializer}}
85
-
_ =UnsafePointer<Int>(mrp) // expected-error {{no exact matches in call to initializer}}
86
-
_ =UnsafePointer<Int>(orp) // expected-error {{no exact matches in call to initializer}}
87
-
_ =UnsafePointer<Int>(omrp) // expected-error {{no exact matches in call to initializer}}
84
+
_ =UnsafePointer<Int>(rp) // expected-error {{cannot convert value of type 'UnsafeRawPointer' to expected argument type 'UnsafePointer<Int>'}}
85
+
_ =UnsafePointer<Int>(mrp) // expected-error {{cannot convert value of type 'UnsafeMutableRawPointer' to expected argument type 'UnsafePointer<Int>'}}
86
+
_ =UnsafePointer<Int>(orp) // expected-error {{cannot convert value of type 'UnsafeRawPointer?' to expected argument type 'UnsafePointer<Int>'}}
87
+
_ =UnsafePointer<Int>(omrp) // expected-error {{cannot convert value of type 'UnsafeMutableRawPointer?' to expected argument type 'UnsafePointer<Int>'}}
88
88
89
89
_ =UnsafePointer<Int>(ups) // expected-error {{cannot convert value of type 'UnsafePointer<String>' to expected argument type 'UnsafePointer<Int>'}}
90
90
// expected-note@-1 {{arguments to generic parameter 'Pointee' ('String' and 'Int') are expected to be equal}}
0 commit comments