Skip to content

Commit 3792ada

Browse files
committed
[ConstraintSolver] Attempt literal bindings earlier
If the best bindings we could get on the current step are bindings to literal type without any other type variable involved, let's try to attempt them right away, that should help to prune search space.
1 parent 7d80daf commit 3792ada

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

lib/Sema/CSSolver.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,14 +1788,10 @@ bool ConstraintSystem::solveSimplified(
17881788
std::tie(bestBindings, bestTypeVar) = determineBestBindings();
17891789

17901790
// If we have a binding that does not involve type variables, and is
1791-
// not fully bound, and is either not a literal or is a collection
1792-
// literal, or we have no disjunction to attempt instead, go ahead
1793-
// and try the bindings for this type variable.
1794-
if (bestBindings &&
1795-
(!disjunction ||
1796-
(!bestBindings.InvolvesTypeVariables && !bestBindings.FullyBound &&
1797-
(bestBindings.LiteralBinding == LiteralBindingKind::None ||
1798-
bestBindings.LiteralBinding == LiteralBindingKind::Collection)))) {
1791+
// not fully bound, or we have no disjunction to attempt instead,
1792+
// go ahead and try the bindings for this type variable.
1793+
if (bestBindings && (!disjunction || (!bestBindings.InvolvesTypeVariables &&
1794+
!bestBindings.FullyBound))) {
17991795
return tryTypeVariableBindings(solverState->depth, bestTypeVar,
18001796
bestBindings.Bindings, solutions,
18011797
allowFreeTypeVariables);

0 commit comments

Comments
 (0)