@@ -562,10 +562,6 @@ bool ConstraintSystem::tryTypeVariableBindings(
562
562
auto &tc = getTypeChecker ();
563
563
++solverState->NumTypeVariablesBound ;
564
564
565
- // If we've already explored a lot of potential solutions, bail.
566
- if (getExpressionTooComplex (solutions))
567
- return true ;
568
-
569
565
for (unsigned tryCount = 0 ; !anySolved && !bindings.empty (); ++tryCount) {
570
566
// Try each of the bindings in turn.
571
567
++solverState->NumTypeVariableBindings ;
@@ -1459,15 +1455,7 @@ ConstraintSystem::solveImpl(Expr *&expr,
1459
1455
1460
1456
// If there are no solutions let's mark system as unsolved,
1461
1457
// and solved otherwise even if there are multiple solutions still present.
1462
-
1463
- // There was a Swift 3 bug that allowed us to return Solved if we
1464
- // had found at least one solution before deciding an expression was
1465
- // "too complex". Maintain that behavior, but for Swift > 3 return
1466
- // Unsolved in these cases.
1467
- auto tooComplex = getExpressionTooComplex (solutions);
1468
- auto unsolved = tooComplex || solutions.empty ();
1469
-
1470
- return unsolved ? SolutionKind::Unsolved : SolutionKind::Solved;
1458
+ return solutions.empty () ? SolutionKind::Unsolved : SolutionKind::Solved;
1471
1459
}
1472
1460
1473
1461
bool ConstraintSystem::solve (Expr *const expr,
@@ -1498,8 +1486,8 @@ bool ConstraintSystem::solve(Expr *const expr,
1498
1486
if (!retainAllSolutions ())
1499
1487
filterSolutions (solutions, state.ExprWeights );
1500
1488
1501
- // We fail if there is no solution.
1502
- return solutions.empty ();
1489
+ // We fail if there is no solution or the expression was too complex .
1490
+ return solutions.empty () || getExpressionTooComplex (solutions) ;
1503
1491
}
1504
1492
1505
1493
bool ConstraintSystem::solveRec (SmallVectorImpl<Solution> &solutions,
@@ -2042,10 +2030,6 @@ bool ConstraintSystem::solveForDisjunctionChoices(
2042
2030
break ;
2043
2031
}
2044
2032
2045
- // If the expression was deemed "too complex", stop now and salvage.
2046
- if (getExpressionTooComplex (solutions))
2047
- break ;
2048
-
2049
2033
// Try to solve the system with this option in the disjunction.
2050
2034
SolverScope scope (*this );
2051
2035
++solverState->NumDisjunctionTerms ;
@@ -2116,6 +2100,10 @@ bool ConstraintSystem::solveSimplified(
2116
2100
2117
2101
auto bestBindings = determineBestBindings ();
2118
2102
2103
+ // If we've already explored a lot of potential solutions, bail.
2104
+ if (getExpressionTooComplex (solutions))
2105
+ return true ;
2106
+
2119
2107
// If we have a binding that does not involve type variables, and is
2120
2108
// not fully bound, or we have no disjunction to attempt instead,
2121
2109
// go ahead and try the bindings for this type variable.
@@ -2127,13 +2115,8 @@ bool ConstraintSystem::solveSimplified(
2127
2115
}
2128
2116
2129
2117
if (disjunction) {
2130
- bool foundSolution = solveForDisjunctionChoices (disjunction, solutions,
2131
- allowFreeTypeVariables);
2132
-
2133
- // If we are exiting due to an expression that is too complex, do
2134
- // not allow our caller to continue as if we have been successful.
2135
- auto tooComplex = getExpressionTooComplex (solutions);
2136
- return tooComplex || !foundSolution;
2118
+ return !solveForDisjunctionChoices (disjunction, solutions,
2119
+ allowFreeTypeVariables);
2137
2120
}
2138
2121
2139
2122
// If there are no disjunctions we can't solve this system unless we have
0 commit comments