Skip to content

Commit 1d22773

Browse files
committed
[ConstraintSystem] Only use the new disjunction ordering under -swift-version 5.
This will minimize the chance of breaking code. Currently SwiftLint has one "too complex" expression with this change. Further changes to the solver may improve that situation, and potentially allow us to move this out from -swift-version 5 if we're willing to take the risk of breaking some code as a result.
1 parent d7cf84a commit 1d22773

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

lib/Sema/CSSolver.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,8 +1577,9 @@ Constraint *ConstraintSystem::selectDisjunction() {
15771577
if (auto *disjunction = selectBestBindingDisjunction(*this, disjunctions))
15781578
return disjunction;
15791579

1580-
if (auto *disjunction = selectApplyDisjunction())
1581-
return disjunction;
1580+
if (getASTContext().isSwiftVersionAtLeast(5))
1581+
if (auto *disjunction = selectApplyDisjunction())
1582+
return disjunction;
15821583

15831584
// Pick the disjunction with the smallest number of active choices.
15841585
auto minDisjunction =
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-expression-time-threshold=1 -swift-version 4
1+
// RUN: %target-typecheck-verify-swift -solver-expression-time-threshold=1 -swift-version 5
22
// REQUIRES: tools-release,no_asserts
33

44
let _ = 1 | UInt32(0) << 0 | UInt32(1) << 1 | UInt32(2) << 2 | UInt32(3) << 3 | UInt32(4) << 4

validation-test/Sema/type_checker_perf/slow/expression_too_complex_4.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 -swift-version 4 -solver-expression-time-threshold=1
1+
// RUN: %target-typecheck-verify-swift -swift-version 4 -solver-expression-time-threshold=1 -swift-version 5
22
// REQUIRES: tools-release,no_asserts
33

44
func test(_ i: Int, _ j: Int) -> Int {

validation-test/Sema/type_checker_perf/slow/rdar22022980.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-expression-time-threshold=1
1+
// RUN: %target-typecheck-verify-swift -solver-expression-time-threshold=1 -swift-version 5
22
// REQUIRES: tools-release,no_asserts
33

44
_ = [1, 3, 5, 7, 11].filter{ $0 == 1 || $0 == 3 || $0 == 11 || $0 == 1 || $0 == 3 || $0 == 11 } == [ 1, 3, 11 ]

0 commit comments

Comments
 (0)