@@ -732,10 +732,34 @@ AllowFunctionTypeMismatch::create(ConstraintSystem &cs, Type lhs, Type rhs,
732
732
AllowFunctionTypeMismatch (cs, lhs, rhs, locator, index);
733
733
}
734
734
735
+ bool GenericArgumentsMismatch::coalesceAndDiagnose (
736
+ const Solution &solution, ArrayRef<ConstraintFix *> secondaryFixes,
737
+ bool asNote) const {
738
+ std::set<unsigned > scratch (getMismatches ().begin (), getMismatches ().end ());
739
+
740
+ for (auto *fix : secondaryFixes) {
741
+ auto *genericArgsFix = fix->castTo <GenericArgumentsMismatch>();
742
+ for (auto mismatchIdx : genericArgsFix->getMismatches ())
743
+ scratch.insert (mismatchIdx);
744
+ }
745
+
746
+ SmallVector<unsigned > mismatches (scratch.begin (), scratch.end ());
747
+ // Make sure that notes about generic arguments are always produced in order.
748
+ llvm::array_pod_sort (mismatches.begin (), mismatches.end ());
749
+
750
+ return diagnose (solution, mismatches, asNote);
751
+ }
752
+
753
+ bool GenericArgumentsMismatch::diagnose (const Solution &solution,
754
+ bool asNote) const {
755
+ return diagnose (solution, getMismatches (), asNote);
756
+ }
757
+
735
758
bool GenericArgumentsMismatch::diagnose (const Solution &solution,
759
+ ArrayRef<unsigned > mismatches,
736
760
bool asNote) const {
737
761
GenericArgumentsMismatchFailure failure (solution, getFromType (), getToType (),
738
- getMismatches () , getLocator ());
762
+ mismatches , getLocator ());
739
763
return failure.diagnose (asNote);
740
764
}
741
765
0 commit comments