@@ -9132,16 +9132,23 @@ Optional<SolutionApplicationTarget> ConstraintSystem::applySolution(
91329132 Solution &solution, SolutionApplicationTarget target) {
91339133 // If any fixes needed to be applied to arrive at this solution, resolve
91349134 // them to specific expressions.
9135+ unsigned numResolvableFixes = 0 ;
91359136 if (!solution.Fixes .empty ()) {
91369137 if (shouldSuppressDiagnostics ())
91379138 return None;
91389139
91399140 bool diagnosedErrorsViaFixes = applySolutionFixes (solution);
9141+ bool canApplySolution = true ;
9142+ for (const auto fix : solution.Fixes ) {
9143+ if (!fix->canApplySolution ())
9144+ canApplySolution = false ;
9145+ if (fix->affectsSolutionScore () == SK_Fix && fix->canApplySolution ())
9146+ ++numResolvableFixes;
9147+ }
9148+
91409149 // If all of the available fixes would result in a warning,
91419150 // we can go ahead and apply this solution to AST.
9142- if (!llvm::all_of (solution.Fixes , [](const ConstraintFix *fix) {
9143- return fix->canApplySolution ();
9144- })) {
9151+ if (!canApplySolution) {
91459152 // If we already diagnosed any errors via fixes, that's it.
91469153 if (diagnosedErrorsViaFixes)
91479154 return None;
@@ -9158,7 +9165,7 @@ Optional<SolutionApplicationTarget> ConstraintSystem::applySolution(
91589165 // produce a fallback diagnostic to highlight the problem.
91599166 {
91609167 const auto &score = solution.getFixedScore ();
9161- if (score.Data [SK_Fix] > 0 || score.Data [SK_Hole] > 0 ) {
9168+ if (score.Data [SK_Fix] > numResolvableFixes || score.Data [SK_Hole] > 0 ) {
91629169 maybeProduceFallbackDiagnostic (target);
91639170 return None;
91649171 }
0 commit comments