[Constraint solver] Simplify one-way constraints to Equal, not Bind.

One-way constraint expressions, which are the only things that
introduce one-way constraints at this point, want to look through
lvalue types to produce values. Rename OneWayBind to OneWayEqual, map
it down to an Equal constraint when it is simplified (to drop
lvalue-ness), and apply that coercion during constraint application.

Part of rdar://problem/50150793.
This commit is contained in:
Doug Gregor
2019-08-16 13:38:58 -07:00
parent da267bf7ca
commit 17ea39accd
10 changed files with 43 additions and 36 deletions

View File

@@ -384,7 +384,7 @@ llvm::TinyPtrVector<Constraint *> ConstraintGraph::gatherConstraints(
// For a one-way constraint, only consider it when the type variable
// is on the right-hand side of the the binding, and the left-hand side of
// the binding is one of the type variables currently under consideration.
if (constraint->getKind() == ConstraintKind::OneWayBind) {
if (constraint->isOneWayConstraint()) {
auto lhsTypeVar =
constraint->getFirstType()->castTo<TypeVariableType>();
if (!CS.isActiveTypeVariable(lhsTypeVar))
@@ -633,7 +633,7 @@ namespace {
continue;
TypeVariableType *typeVar;
if (constraint.getKind() == ConstraintKind::OneWayBind) {
if (constraint.isOneWayConstraint()) {
// For one-way constraints, associate the constraint with the
// left-hand type variable.
typeVar = constraint.getFirstType()->castTo<TypeVariableType>();
@@ -780,7 +780,7 @@ namespace {
},
[&](Constraint *constraint) {
// Record and skip one-way constraints.
if (constraint->getKind() == ConstraintKind::OneWayBind) {
if (constraint->isOneWayConstraint()) {
oneWayConstraints.push_back(constraint);
return false;
}