@@ -2719,6 +2719,11 @@ SolutionResult ConstraintSystem::salvage() {
2719
2719
// Solve the system.
2720
2720
solveImpl (viable);
2721
2721
2722
+ // Before removing any "fixed" solutions, let's check
2723
+ // if ambiguity is caused by fixes and diagnose if possible.
2724
+ if (diagnoseAmbiguityWithFixes (viable))
2725
+ return SolutionResult::forAmbiguous (viable);
2726
+
2722
2727
// Check whether we have a best solution; this can happen if we found
2723
2728
// a series of fixes that worked.
2724
2729
if (auto best = findBestSolution (viable, /* minimize=*/ true )) {
@@ -2728,11 +2733,6 @@ SolutionResult ConstraintSystem::salvage() {
2728
2733
return SolutionResult::forSolved (std::move (viable[0 ]));
2729
2734
}
2730
2735
2731
- // Before removing any "fixed" solutions, let's check
2732
- // if ambiguity is caused by fixes and diagnose if possible.
2733
- if (diagnoseAmbiguityWithFixes (viable))
2734
- return SolutionResult::forAmbiguous (viable);
2735
-
2736
2736
// FIXME: If we were able to actually fix things along the way,
2737
2737
// we may have to hunt for the best solution. For now, we don't care.
2738
2738
@@ -3071,7 +3071,7 @@ bool ConstraintSystem::diagnoseAmbiguityWithFixes(
3071
3071
3072
3072
if (diagnoseConflictingGenericArguments (*this , solutionDiff, solutions))
3073
3073
return true ;
3074
-
3074
+
3075
3075
if (auto bestScore = solverState->BestScore ) {
3076
3076
solutions.erase (llvm::remove_if (solutions,
3077
3077
[&](const Solution &solution) {
@@ -3087,6 +3087,9 @@ bool ConstraintSystem::diagnoseAmbiguityWithFixes(
3087
3087
return false ;
3088
3088
}
3089
3089
3090
+ if (solutions.size () < 2 )
3091
+ return false ;
3092
+
3090
3093
if (diagnoseAmbiguityWithEphemeralPointers (*this , solutions))
3091
3094
return true ;
3092
3095
0 commit comments