Skip to content

Commit f12efe9

Browse files
committed
[CSBindings] Use matchTypes directly while attempting a type variable
This makes sure that solver knows the result of a bind, instead of having to checking `failedConstraint` and allows passing flags.
1 parent 166c41d commit f12efe9

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/Sema/CSBindings.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,7 +1793,15 @@ bool TypeVariableBinding::attempt(ConstraintSystem &cs) const {
17931793
type = type->reconstituteSugar(/*recursive=*/false);
17941794
}
17951795

1796-
cs.addConstraint(ConstraintKind::Bind, TypeVar, type, srcLocator);
1796+
ConstraintSystem::TypeMatchOptions options;
1797+
1798+
options |= ConstraintSystem::TMF_GenerateConstraints;
1799+
1800+
auto result =
1801+
cs.matchTypes(TypeVar, type, ConstraintKind::Bind, options, srcLocator);
1802+
1803+
if (result.isFailure())
1804+
return false;
17971805

17981806
auto reportHole = [&]() {
17991807
if (cs.isForCodeCompletion()) {
@@ -1825,5 +1833,5 @@ bool TypeVariableBinding::attempt(ConstraintSystem &cs) const {
18251833
return true;
18261834
}
18271835

1828-
return !cs.failedConstraint && !cs.simplify();
1836+
return !cs.simplify();
18291837
}

0 commit comments

Comments
 (0)