[CSSimplify] Increase score if conformance constraint finds missing conformances

Although the solver is allowed to use types with missing synthesizable
conformances we need to note their presence in the score in order
to rank overloads without such types higher.
This commit is contained in:
Pavel Yaskevich
2023-10-31 11:39:32 -07:00
parent b13c2194c5
commit d0fae407f3
2 changed files with 40 additions and 0 deletions

View File

@@ -8412,6 +8412,16 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
if (isConformanceUnavailable(conformance, loc))
increaseScore(SK_Unavailable, locator);
unsigned numMissing = 0;
conformance.forEachMissingConformance(DC->getParentModule(),
[&numMissing](auto *missing) {
++numMissing;
return false;
});
if (numMissing > 0)
increaseScore(SK_MissingSynthesizableConformance, locator, numMissing);
// This conformance may be conditional, in which case we need to consider
// those requirements as constraints too.
if (conformance.isConcrete()) {