[Constraint solver] Don't reprocess constraints known to be unsolvable.

When we're creating a new constraint because we couldn't solve it (and
need to record the result), do so without trying to simplify it yet
again. It's just wasted work.
This commit is contained in:
Doug Gregor
2016-10-20 21:27:02 -07:00
parent b69d01eef2
commit a4fc0aaad2
3 changed files with 23 additions and 13 deletions

View File

@@ -1196,8 +1196,11 @@ ConstraintSystem::matchTypes(Type type1, Type type2, TypeMatchKind kind,
// this new constraint will be solved at a later point.
// Obviously, this must not happen at the top level, or the
// algorithm would not terminate.
addConstraint(getConstraintKind(kind), type1, type2,
getConstraintLocator(locator));
addUnsolvedConstraint(Constraint::create(*this,
getConstraintKind(kind),
type1, type2, DeclName(),
FunctionRefKind::Compound,
getConstraintLocator(locator)));
return SolutionKind::Solved;
}
@@ -3672,7 +3675,9 @@ ConstraintSystem::simplifyRestrictedConstraint(ConversionRestrictionKind restric
getConstraintLocator(locator));
Constraint *disjunctionChoices[] = {int8Con, uint8Con, voidCon};
addDisjunctionConstraint(disjunctionChoices, locator);
addUnsolvedConstraint(
Constraint::createDisjunction(*this, disjunctionChoices,
getConstraintLocator(locator)));
return SolutionKind::Solved;
}