Skip to content

Commit 4f4fcf6

Browse files
committed
[ConstraintSystem] Decouple designated types feature from Swift version
`selectApplyDisjunction` only makes sense in conjunction with designated types feature because it's going to prioritize disjunctions with arguments which are known to conform to literal protocols. Prioritization like that is harmful without designated types feature because it doesn't always lead to better constraint system splits, and could prioritize bigger disjunctions which harms chances to short-circuit solving. Resolves: rdar://problem/47492691 (cherry picked from commit 0b29d9d)
1 parent 77d1c02 commit 4f4fcf6

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/Sema/CSSolver.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1956,9 +1956,10 @@ Constraint *ConstraintSystem::selectDisjunction() {
19561956
// disjunctions that we may not be able to short-circuit, allowing
19571957
// us to eliminate behavior that is exponential in the number of
19581958
// operators in the expression.
1959-
if (getASTContext().isSwiftVersionAtLeast(5))
1959+
if (TC.getLangOpts().SolverEnableOperatorDesignatedTypes) {
19601960
if (auto *disjunction = selectApplyDisjunction())
19611961
return disjunction;
1962+
}
19621963

19631964
if (auto *disjunction = selectBestBindingDisjunction(*this, disjunctions))
19641965
return disjunction;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %target-typecheck-verify-swift
2+
// REQUIRES: objc_interop
3+
4+
import CoreGraphics
5+
import simd
6+
7+
func test(foo: CGFloat, bar: CGFloat) {
8+
_ = CGRect(x: 0.0 + 1.0, y: 0.0 + foo, width: 3.0 - 1 - 1 - 1.0, height: bar)
9+
}

0 commit comments

Comments
 (0)