Skip to content

Commit 1760bd1

Browse files
committed
[CSOptimizer] Remove an outdated optimization to compare resolved argument types with all else equal
This is already accounted for by `determineBestChoicesInContext` and reflected in the overall score, which means that we no longer need to use this in vacuum.
1 parent c429f5b commit 1760bd1

File tree

3 files changed

+0
-23
lines changed

3 files changed

+0
-23
lines changed

include/swift/Sema/Constraint.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -825,11 +825,6 @@ class Constraint final : public llvm::ilist_node<Constraint>,
825825
});
826826
}
827827

828-
/// Returns the number of resolved argument types for an applied disjunction
829-
/// constraint. This is always zero for disjunctions that do not represent
830-
/// an applied overload.
831-
unsigned countResolvedArgumentTypes(ConstraintSystem &cs) const;
832-
833828
/// Determine if this constraint represents explicit conversion,
834829
/// e.g. coercion constraint "as X" which forms a disjunction.
835830
bool isExplicitConversion() const;

lib/Sema/CSOptimizer.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -662,16 +662,9 @@ ConstraintSystem::selectDisjunction() {
662662
unsigned firstFavored = favorings[first].size();
663663
unsigned secondFavored = favorings[second].size();
664664

665-
// Everything else equal, choose the disjunction with the greatest
666-
// number of resolved argument types. The number of resolved argument
667-
// types is always zero for disjunctions that don't represent applied
668-
// overloads.
669665
if (firstFavored == secondFavored) {
670666
if (firstActive != secondActive)
671667
return firstActive < secondActive;
672-
673-
return first->countResolvedArgumentTypes(*this) >
674-
second->countResolvedArgumentTypes(*this);
675668
}
676669

677670
firstFavored = firstFavored ? firstFavored : firstActive;

lib/Sema/Constraint.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -711,17 +711,6 @@ gatherReferencedTypeVars(Constraint *constraint,
711711
}
712712
}
713713

714-
unsigned Constraint::countResolvedArgumentTypes(ConstraintSystem &cs) const {
715-
auto *argumentFuncType = cs.getAppliedDisjunctionArgumentFunction(this);
716-
if (!argumentFuncType)
717-
return 0;
718-
719-
return llvm::count_if(argumentFuncType->getParams(), [&](const AnyFunctionType::Param arg) {
720-
auto argType = cs.getFixedTypeRecursive(arg.getPlainType(), /*wantRValue=*/true);
721-
return !argType->isTypeVariableOrMember();
722-
});
723-
}
724-
725714
bool Constraint::isExplicitConversion() const {
726715
assert(Kind == ConstraintKind::Disjunction);
727716

0 commit comments

Comments
 (0)