Skip to content

Commit 961a319

Browse files
authored
Merge pull request #8799 from rudkx/propagate-constraints
2 parents 272eb46 + 5e6b4a9 commit 961a319

File tree

4 files changed

+10
-42
lines changed

4 files changed

+10
-42
lines changed

lib/Sema/CSPropagate.cpp

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ getBindOverloadDisjunction(ConstraintSystem &CS, Constraint *applicableFn) {
6969
return found;
7070
}
7171

72-
bool ConstraintSystem::collectNeighboringBindOverloadDisjunctions(
72+
void ConstraintSystem::collectNeighboringBindOverloadDisjunctions(
7373
llvm::SetVector<Constraint *> &neighbors) {
74-
bool failed = false;
7574

7675
while (!ActiveConstraints.empty()) {
7776
auto *constraint = &ActiveConstraints.front();
@@ -87,32 +86,14 @@ bool ConstraintSystem::collectNeighboringBindOverloadDisjunctions(
8786
} else if (constraint->getKind() == ConstraintKind::ApplicableFunction) {
8887
if (auto *bindDisjunction =
8988
getBindOverloadDisjunction(*this, constraint)) {
90-
// FIXME: should we bind this now so that we do something when
91-
// we test the applicable constraint?
9289
neighbors.insert(bindDisjunction);
9390
}
9491
}
9592

96-
// Simplify this constraint.
97-
switch (simplifyConstraint(*constraint)) {
98-
case SolutionKind::Error:
99-
failed = true;
100-
LLVM_FALLTHROUGH;
101-
102-
case SolutionKind::Solved:
103-
solverState->retireConstraint(constraint);
104-
CG.removeConstraint(constraint);
105-
break;
106-
107-
case SolutionKind::Unsolved:
108-
InactiveConstraints.push_back(constraint);
109-
break;
110-
}
111-
93+
solverState->retireConstraint(constraint);
94+
CG.removeConstraint(constraint);
11295
constraint->setActive(false);
11396
}
114-
115-
return !failed;
11697
}
11798

11899
// Simplify any active constraints, returning true on success, false
@@ -218,21 +199,7 @@ bool ConstraintSystem::isBindOverloadConsistent(
218199
solverState->retireConstraint(bindConstraint);
219200
solverState->addGeneratedConstraint(bindConstraint);
220201

221-
auto passed = collectNeighboringBindOverloadDisjunctions(otherDisjunctions);
222-
if (!passed) {
223-
if (TC.getLangOpts().DebugConstraintSolver) {
224-
auto &log = getASTContext().TypeCheckerDebug->getStream();
225-
log << "Disabling bind constraint: ";
226-
bindConstraint->print(log, &TC.Context.SourceMgr);
227-
log << "\n";
228-
}
229-
230-
bindConstraint->setDisabled();
231-
for (auto *disjunction : otherDisjunctions)
232-
workList.insert(disjunction);
233-
234-
return false;
235-
}
202+
collectNeighboringBindOverloadDisjunctions(otherDisjunctions);
236203
}
237204

238205
// Test the our primary constraint against all of the members of

lib/Sema/ConstraintSystem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2362,7 +2362,7 @@ class ConstraintSystem {
23622362
void shrink(Expr *expr);
23632363

23642364
bool simplifyForConstraintPropagation();
2365-
bool collectNeighboringBindOverloadDisjunctions(
2365+
void collectNeighboringBindOverloadDisjunctions(
23662366
llvm::SetVector<Constraint *> &neighbors);
23672367
bool isBindOverloadConsistent(Constraint *bindConstraint,
23682368
llvm::SetVector<Constraint *> &workList);

test/Misc/expression_too_complex.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// RUN: %target-typecheck-verify-swift -solver-memory-threshold 8000
1+
// RUN: %target-typecheck-verify-swift -solver-memory-threshold 10000 -propagate-constraints
22

3-
var x = [1, 2, 3, 4.5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 ,19] // expected-error{{expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions}}
3+
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

55
// No errors should appear below as a result of the error above.
6+
var x = [1, 2, 3, 4.5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 ,19]
67
var y = 10
7-
var z = 10 + 10
88

99
class C {}
1010

test/Sema/complex_expressions.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift
1+
// RUN: %target-typecheck-verify-swift -propagate-constraints
22

33
// SR-139:
44
// Infinite recursion parsing bitwise operators
@@ -93,6 +93,7 @@ func sr1794(pt: P, p0: P, p1: P) -> Bool {
9393
let v1 = (1 - 2 / 3 * 6) as UInt
9494
let v2 = (([1 + 2 * 3, 4, 5])) as [UInt]
9595
let v3 = ["hello": 1 + 2, "world": 3 + 4 + 5 * 3] as Dictionary<String, UInt>
96+
// expected-error@-1 {{ambiguous use of operator '+'}}
9697
let v4 = [1 + 2 + 3, 4] as [UInt32] + [2 * 3] as [UInt32]
9798
let v5 = ([1 + 2 + 3, 4] as [UInt32]) + ([2 * 3] as [UInt32])
9899
let v6 = [1 + 2 + 3, 4] as Set<UInt32>

0 commit comments

Comments
 (0)