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
[ConstraintSystem] Do more checking before suggesting to explicitly contruct raw representable
Introduce `repairByExplicitRawRepresentativeUse` which is used for
assignment, argument-to-parameter conversions and contextual mismatches.
It checks whether `to` side is a raw representable type and tries
to match `from` side to its `rawValue`.
// rdar://problem/32431165 - improve diagnostic for raw representable argument mismatch
@@ -122,9 +122,9 @@ rdar32431165_1(.baz)
122
122
// expected-error@-1 {{reference to member 'baz' cannot be resolved without a contextual type}}
123
123
124
124
rdar32431165_1("")
125
-
// expected-error@-1 {{cannot convert value of type 'String' to expected argument type 'E_32431165'}} {{16-16=E_32431165(rawValue: }} {{18-18=)}}
125
+
// expected-error@-1 {{cannot convert value of type 'String' to expected argument type 'E_32431165'}}
126
126
rdar32431165_1(42,"")
127
-
// expected-error@-1 {{cannot convert value of type 'String' to expected argument type 'E_32431165'}} {{20-20=E_32431165(rawValue: }} {{22-22=)}}
127
+
// expected-error@-1 {{cannot convert value of type 'String' to expected argument type 'E_32431165'}} {{20-20=E_32431165(rawValue: }} {{22-22=) ?? <#default value#>}}
128
128
129
129
func rdar32431165_2(_:String){}
130
130
func rdar32431165_2(_:Int){}
@@ -141,6 +141,16 @@ E_32431165.bar == "bar"
141
141
"bar"==E_32431165.bar
142
142
// expected-error@-1 {{cannot convert value of type 'E_32431165' to expected argument type 'String}} {{10-10=}} {{24-24=.rawValue}}
143
143
144
+
func rdar32431165_overloaded()->Int{42} // expected-note {{found candidate with type 'Int'}}
145
+
func rdar32431165_overloaded()->String{"A"} // expected-note {{'rdar32431165_overloaded()' produces 'String', not the expected contextual result type 'E_32431165'}}
146
+
147
+
func test_candidate_diagnostic(){
148
+
func test_argument(_:E_32431165){}
149
+
150
+
let _:E_32431165=rdar32431165_overloaded() // expected-error {{no exact matches in call to global function 'rdar32431165_overloaded'}}
151
+
test_argument(rdar32431165_overloaded()) // expected-error {{cannot convert value of type 'String' to expected argument type 'E_32431165'}} {{17-17=E_32431165(rawValue: }} {{42-42=) ?? <#default value#>}}
152
+
}
153
+
144
154
func rdar32432253(_ condition:Bool=false){
145
155
letchoice:E_32431165= condition ?.foo :.bar
146
156
let _ = choice =="bar"
@@ -165,9 +175,9 @@ func sr8150(bar: Bar) {
165
175
sr8150_helper2(bar)
166
176
// expected-error@-1 {{cannot convert value of type 'Bar' to expected argument type 'Double'}} {{18-18=}} {{21-21=.rawValue}}
167
177
sr8150_helper3(0.0)
168
-
// expected-error@-1 {{cannot convert value of type 'Double' to expected argument type 'Bar'}} {{18-18=Bar(rawValue: }} {{21-21=)}}
178
+
// expected-error@-1 {{cannot convert value of type 'Double' to expected argument type 'Bar'}} {{18-18=Bar(rawValue: }} {{21-21=) ?? <#default value#>}}
169
179
sr8150_helper4(0.0)
170
-
// expected-error@-1 {{cannot convert value of type 'Double' to expected argument type 'Bar'}} {{18-18=Bar(rawValue: }} {{21-21=)}}
180
+
// expected-error@-1 {{cannot convert value of type 'Double' to expected argument type 'Bar'}} {{18-18=Bar(rawValue: }} {{21-21=) ?? <#default value#>}}
0 commit comments