[Sema] Add conditional requirements as CS constraints.

This tries to feed through the constraint system all the constraints
implied by a concrete type satisfying a conformance requirement.
This commit is contained in:
Huon Wilson
2017-09-28 22:48:11 +10:00
parent 8e50a1666f
commit f6729f17d6
2 changed files with 104 additions and 4 deletions

View File

@@ -2604,6 +2604,16 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
ConformanceCheckFlags::InExpression)) {
CheckedConformances.push_back({getConstraintLocator(locator),
*conformance});
// This conformance may be conditional, in which case we need to consider
// those requirements as constraints too.
//
// FIXME: this doesn't seem to be right; the requirements are sometimes
// phrased in terms of the type's generic parameters, not type variables
// in this context.
for (auto req : conformance->getConditionalRequirements()) {
addConstraint(req, locator);
}
return SolutionKind::Solved;
}
break;