Diagnostics: Ported tuple mismatch diagnostic to new diagnostic framework

This commit is contained in:
Sam Lazarus
2019-07-23 15:28:53 -04:00
parent b28b44b9c7
commit a3b56c2790
9 changed files with 115 additions and 14 deletions

View File

@@ -1147,9 +1147,9 @@ bool FailureDiagnosis::diagnoseGeneralConversionFailure(Constraint *constraint){
if (auto fromTT = fromType->getAs<TupleType>())
if (auto toTT = toType->getAs<TupleType>()) {
if (fromTT->getNumElements() != toTT->getNumElements()) {
diagnose(anchor->getLoc(), diag::tuple_types_not_convertible_nelts,
fromTT, toTT)
.highlight(anchor->getSourceRange());
auto failure = TupleContextualFailure(anchor, CS, fromTT, toTT,
CS.getConstraintLocator(expr));
failure.diagnoseAsError();
return true;
}
@@ -1166,9 +1166,9 @@ bool FailureDiagnosis::diagnoseGeneralConversionFailure(Constraint *constraint){
// then we have a type error.
if (computeTupleShuffle(TEType->castTo<TupleType>()->getElements(),
toTT->getElements(), sources)) {
diagnose(anchor->getLoc(), diag::tuple_types_not_convertible,
fromTT, toTT)
.highlight(anchor->getSourceRange());
auto failure = TupleContextualFailure(anchor, CS, fromTT, toTT,
CS.getConstraintLocator(expr));
failure.diagnoseAsError();
return true;
}
}