Skip to content

Commit 9e7b5b2

Browse files
committed
Remove -swift-version 3 checks for "expression too complex".
This was initially added to avoid "expression was too complex" in a case where we were not previously reporting it for -swift-version 3 but should have been. In retrospect this seems misguided since although we would not like to regress on "too complex" expressions, we really don't want to silently continue in the cases where we decide an expression is "too complex", but where we have a solution that we could use. It's better to fail.
1 parent 16c6649 commit 9e7b5b2

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

lib/Sema/CSSolver.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,8 +1342,7 @@ ConstraintSystem::solve(Expr *&expr,
13421342
// had found at least one solution before deciding an expression was
13431343
// "too complex". Maintain that behavior, but for Swift > 3 return
13441344
// Unsolved in these cases.
1345-
auto tooComplex = getExpressionTooComplex(solutions) &&
1346-
!getASTContext().isSwiftVersion3();
1345+
auto tooComplex = getExpressionTooComplex(solutions);
13471346
auto unsolved = tooComplex || solutions.empty();
13481347

13491348
return unsolved ? SolutionKind::Unsolved : SolutionKind::Solved;
@@ -1876,9 +1875,7 @@ bool ConstraintSystem::solveSimplified(
18761875
// not allow our caller to continue as if we have been successful.
18771876
// Maintain the broken behavior under Swift 3 mode though, to avoid
18781877
// breaking code.
1879-
auto tooComplex = getExpressionTooComplex(solutions) &&
1880-
!getASTContext().isSwiftVersion3();
1881-
1878+
auto tooComplex = getExpressionTooComplex(solutions);
18821879
return tooComplex || !lastSolvedChoice;
18831880
}
18841881

test/Misc/expression_too_complex.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift -solver-memory-threshold 12000 -propagate-constraints
1+
// RUN: %target-typecheck-verify-swift -solver-memory-threshold 16000 -propagate-constraints
22

33
var z = 10 + 10 // expected-error{{expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions}}
44

0 commit comments

Comments
 (0)