Omit recording conversion restrictions in a solution that apply can just as easily figure out itself from the shape of the types.

This commit is contained in:
gregomni
2018-08-03 11:02:04 -07:00
parent ecdfb5d8fb
commit a37229e40a
2 changed files with 22 additions and 29 deletions

View File

@@ -4879,6 +4879,19 @@ ConstraintSystem::simplifyRestrictedConstraintImpl(
llvm_unreachable("bad conversion restriction");
}
// Restrictions where CSApply can figure out the correct action from the shape of
// the types, rather than needing a record of the choice made.
static bool recordRestriction(ConversionRestrictionKind restriction) {
switch(restriction) {
case ConversionRestrictionKind::TupleToTuple:
case ConversionRestrictionKind::ScalarToTuple:
case ConversionRestrictionKind::LValueToRValue:
return false;
default:
return true;
}
}
ConstraintSystem::SolutionKind
ConstraintSystem::simplifyRestrictedConstraint(
ConversionRestrictionKind restriction,
@@ -4889,8 +4902,8 @@ ConstraintSystem::simplifyRestrictedConstraint(
switch (simplifyRestrictedConstraintImpl(restriction, type1, type2,
matchKind, flags, locator)) {
case SolutionKind::Solved:
ConstraintRestrictions.push_back(
std::make_tuple(type1, type2, restriction));
if (recordRestriction(restriction))
ConstraintRestrictions.push_back(std::make_tuple(type1, type2, restriction));
return SolutionKind::Solved;
case SolutionKind::Unsolved: