Skip to content

Commit 0e6198d

Browse files
committed
[CSSolver] Shrinking should avoid solutions with implicit conversions
Just like generic overloads, `shrink` should always avoid any solutions with implicit conversions. Reducing disjunction domains becaused on solutions with implicit conversions could have negative performance impact due to the increase in total number of solutions that have to be examined as a result.
1 parent 307caf2 commit 0e6198d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: lib/Sema/CSSolver.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,14 @@ void ConstraintSystem::Candidate::applySolutions(
742742
llvm::SmallDenseMap<OverloadSetRefExpr *, llvm::SmallSetVector<ValueDecl *, 2>>
743743
domains;
744744
for (auto &solution : solutions) {
745+
auto &score = solution.getFixedScore();
746+
747+
// Avoid any solutions with implicit value conversions
748+
// because they might get reverted later when more context
749+
// becomes available.
750+
if (score.Data[SK_ImplicitValueConversion] > 0)
751+
continue;
752+
745753
for (auto choice : solution.overloadChoices) {
746754
// Some of the choices might not have locators.
747755
if (!choice.getFirst())

0 commit comments

Comments
 (0)