@@ -6407,7 +6407,12 @@ bool MissingRawRepresentativeInitFailure::diagnoseAsError() {
6407
6407
return false ;
6408
6408
6409
6409
auto diagnostic = emitDiagnostic (*message, ValueType, RawReprType);
6410
+ fixIt (diagnostic);
6411
+ return true ;
6412
+ }
6410
6413
6414
+ void MissingRawRepresentativeInitFailure::fixIt (
6415
+ InFlightDiagnostic &diagnostic) const {
6411
6416
if (auto *E = getAsExpr (getAnchor ())) {
6412
6417
auto range = E->getSourceRange ();
6413
6418
auto rawReprObjType = RawReprType->getOptionalObjectType ();
@@ -6455,6 +6460,33 @@ bool MissingRawRepresentativeInitFailure::diagnoseAsError() {
6455
6460
.fixItInsertAfter (range.End , " ) ?? <#default value#>" );
6456
6461
}
6457
6462
}
6463
+ }
6458
6464
6459
- return true ;
6465
+ bool MissingRawRepresentativeInitFailure::diagnoseAsNote () {
6466
+ auto *locator = getLocator ();
6467
+
6468
+ Optional<InFlightDiagnostic> diagnostic;
6469
+ if (locator->isForContextualType ()) {
6470
+ auto overload = getCalleeOverloadChoiceIfAvailable (locator);
6471
+ if (!overload)
6472
+ return false ;
6473
+
6474
+ if (auto *decl = overload->choice .getDeclOrNull ()) {
6475
+ diagnostic.emplace (emitDiagnosticAt (
6476
+ decl, diag::cannot_convert_candidate_result_to_contextual_type,
6477
+ decl->getName (), ValueType, RawReprType));
6478
+ }
6479
+ } else if (auto argConv =
6480
+ locator->getLastElementAs <LocatorPathElt::ApplyArgToParam>()) {
6481
+ diagnostic.emplace (
6482
+ emitDiagnostic (diag::candidate_has_invalid_argument_at_position,
6483
+ RawReprType, argConv->getParamIdx (), /* inOut=*/ false ));
6484
+ }
6485
+
6486
+ if (diagnostic) {
6487
+ fixIt (*diagnostic);
6488
+ return true ;
6489
+ }
6490
+
6491
+ return false ;
6460
6492
}
0 commit comments