@@ -2770,14 +2770,22 @@ static bool diagnoseConflictingGenericArguments(ConstraintSystem &cs,
2770
2770
if (!diff.overloads .empty ())
2771
2771
return false ;
2772
2772
2773
- if (!llvm::all_of (solutions, [](const Solution &solution) -> bool {
2773
+ bool noFixes = llvm::all_of (solutions, [](const Solution &solution) -> bool {
2774
+ const auto score = solution.getFixedScore ();
2775
+ return score.Data [SK_Fix] == 0 && solution.Fixes .empty ();
2776
+ });
2777
+
2778
+ bool allMismatches =
2779
+ llvm::all_of (solutions, [](const Solution &solution) -> bool {
2774
2780
return llvm::all_of (
2775
2781
solution.Fixes , [](const ConstraintFix *fix) -> bool {
2776
2782
return fix->getKind () == FixKind::AllowArgumentTypeMismatch ||
2777
2783
fix->getKind () == FixKind::AllowFunctionTypeMismatch ||
2778
2784
fix->getKind () == FixKind::AllowTupleTypeMismatch;
2779
2785
});
2780
- }))
2786
+ });
2787
+
2788
+ if (!noFixes && !allMismatches)
2781
2789
return false ;
2782
2790
2783
2791
auto &DE = cs.getASTContext ().Diags ;
@@ -2930,6 +2938,11 @@ bool ConstraintSystem::diagnoseAmbiguityWithFixes(
2930
2938
if (solutions.empty ())
2931
2939
return false ;
2932
2940
2941
+ SolutionDiff solutionDiff (solutions);
2942
+
2943
+ if (diagnoseConflictingGenericArguments (*this , solutionDiff, solutions))
2944
+ return true ;
2945
+
2933
2946
if (auto bestScore = solverState->BestScore ) {
2934
2947
solutions.erase (llvm::remove_if (solutions,
2935
2948
[&](const Solution &solution) {
@@ -2945,11 +2958,6 @@ bool ConstraintSystem::diagnoseAmbiguityWithFixes(
2945
2958
return false ;
2946
2959
}
2947
2960
2948
- SolutionDiff solutionDiff (solutions);
2949
-
2950
- if (diagnoseConflictingGenericArguments (*this , solutionDiff, solutions))
2951
- return true ;
2952
-
2953
2961
if (diagnoseAmbiguityWithEphemeralPointers (*this , solutions))
2954
2962
return true ;
2955
2963
0 commit comments