Skip to content

Commit c62d898

Browse files
committed
[ConstraintSystem] Only attempt generic overload pruning heuristics for
operators for now.
1 parent 0051c89 commit c62d898

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

lib/Sema/CSSolver.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2178,17 +2178,14 @@ void ConstraintSystem::partitionDisjunction(
21782178
SmallVector<unsigned, 4> genericOverloads;
21792179

21802180
forEachChoice(Choices, [&](unsigned index, Constraint *constraint) -> bool {
2181-
if (!isForCodeCompletion()) {
2181+
if (!isForCodeCompletion() && isOperatorBindOverload(constraint)) {
21822182
// Collect generic overload choices separately, and sort these choices
21832183
// by specificity in order to try the most specific choice first.
2184-
if (constraint->getKind() == ConstraintKind::BindOverload) {
2185-
if (auto *decl = constraint->getOverloadChoice().getDeclOrNull()) {
2186-
auto *fnDecl = dyn_cast<AbstractFunctionDecl>(decl);
2187-
if (fnDecl && fnDecl->isGeneric()) {
2188-
genericOverloads.push_back(index);
2189-
return true;
2190-
}
2191-
}
2184+
auto *decl = constraint->getOverloadChoice().getDecl();
2185+
auto *fnDecl = dyn_cast<AbstractFunctionDecl>(decl);
2186+
if (fnDecl && fnDecl->isGeneric()) {
2187+
genericOverloads.push_back(index);
2188+
return true;
21922189
}
21932190
}
21942191

lib/Sema/CSStep.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -580,18 +580,6 @@ static bool isDeclSubstitutable(ValueDecl *declA, ValueDecl *declB) {
580580
false);
581581
}
582582

583-
static bool isGenericDisjunctionChoice(Constraint *constraint) {
584-
if (constraint->getKind() != ConstraintKind::BindOverload)
585-
return false;
586-
587-
auto choice = constraint->getOverloadChoice();
588-
if (!choice.isDecl())
589-
return false;
590-
591-
auto *funcDecl = dyn_cast<AbstractFunctionDecl>(choice.getDecl());
592-
return funcDecl && funcDecl->isGeneric();
593-
}
594-
595583
bool DisjunctionStep::shouldSkip(const DisjunctionChoice &choice) const {
596584
auto &ctx = CS.getASTContext();
597585

@@ -624,7 +612,7 @@ bool DisjunctionStep::shouldSkip(const DisjunctionChoice &choice) const {
624612
// can be unconditionally substituted by the current choice, skip the current
625613
// choice.
626614
if (LastSolvedChoice && LastSolvedChoice->second == getCurrentScore() &&
627-
isGenericDisjunctionChoice(choice)) {
615+
choice.isGenericOperator()) {
628616
auto *declA = LastSolvedChoice->first->getOverloadChoice().getDecl();
629617
auto *declB = static_cast<Constraint *>(choice)->getOverloadChoice().getDecl();
630618

0 commit comments

Comments
 (0)