@@ -6279,6 +6279,35 @@ bool AbstractRawRepresentableFailure::diagnoseAsError() {
6279
6279
return true ;
6280
6280
}
6281
6281
6282
+ bool AbstractRawRepresentableFailure::diagnoseAsNote () {
6283
+ auto *locator = getLocator ();
6284
+
6285
+ Optional<InFlightDiagnostic> diagnostic;
6286
+ if (locator->isForContextualType ()) {
6287
+ auto overload = getCalleeOverloadChoiceIfAvailable (locator);
6288
+ if (!overload)
6289
+ return false ;
6290
+
6291
+ if (auto *decl = overload->choice .getDeclOrNull ()) {
6292
+ diagnostic.emplace (emitDiagnosticAt (
6293
+ decl, diag::cannot_convert_candidate_result_to_contextual_type,
6294
+ decl->getName (), ExpectedType, RawReprType));
6295
+ }
6296
+ } else if (auto argConv =
6297
+ locator->getLastElementAs <LocatorPathElt::ApplyArgToParam>()) {
6298
+ diagnostic.emplace (
6299
+ emitDiagnostic (diag::candidate_has_invalid_argument_at_position,
6300
+ RawReprType, argConv->getParamIdx (), /* inOut=*/ false ));
6301
+ }
6302
+
6303
+ if (diagnostic) {
6304
+ fixIt (*diagnostic);
6305
+ return true ;
6306
+ }
6307
+
6308
+ return false ;
6309
+ }
6310
+
6282
6311
void MissingRawRepresentativeInitFailure::fixIt (
6283
6312
InFlightDiagnostic &diagnostic) const {
6284
6313
if (auto *E = getAsExpr (getAnchor ())) {
@@ -6330,35 +6359,6 @@ void MissingRawRepresentativeInitFailure::fixIt(
6330
6359
}
6331
6360
}
6332
6361
6333
- bool AbstractRawRepresentableFailure::diagnoseAsNote () {
6334
- auto *locator = getLocator ();
6335
-
6336
- Optional<InFlightDiagnostic> diagnostic;
6337
- if (locator->isForContextualType ()) {
6338
- auto overload = getCalleeOverloadChoiceIfAvailable (locator);
6339
- if (!overload)
6340
- return false ;
6341
-
6342
- if (auto *decl = overload->choice .getDeclOrNull ()) {
6343
- diagnostic.emplace (emitDiagnosticAt (
6344
- decl, diag::cannot_convert_candidate_result_to_contextual_type,
6345
- decl->getName (), ExpectedType, RawReprType));
6346
- }
6347
- } else if (auto argConv =
6348
- locator->getLastElementAs <LocatorPathElt::ApplyArgToParam>()) {
6349
- diagnostic.emplace (
6350
- emitDiagnostic (diag::candidate_has_invalid_argument_at_position,
6351
- RawReprType, argConv->getParamIdx (), /* inOut=*/ false ));
6352
- }
6353
-
6354
- if (diagnostic) {
6355
- fixIt (*diagnostic);
6356
- return true ;
6357
- }
6358
-
6359
- return false ;
6360
- }
6361
-
6362
6362
void UseOfRawRepresentableInsteadOfItsRawValueFailure::fixIt (
6363
6363
InFlightDiagnostic &diagnostic) const {
6364
6364
auto *E = getAsExpr (getAnchor ());
0 commit comments