[ConstraintSystem] Improve type parameter requirement locators

When opening generic types with type parameter requirements,
add information about requirement location to the locator of each
generated constraint to make it easier to extract such information
if needed.
This commit is contained in:
Pavel Yaskevich
2017-11-21 22:46:14 -08:00
parent 6c70718f4c
commit df0fd6abfb
3 changed files with 22 additions and 2 deletions

View File

@@ -1051,7 +1051,10 @@ void ConstraintSystem::openGeneric(
bindArchetypesFromContext(*this, outerDC, locatorPtr, replacements);
// Add the requirements as constraints.
for (auto req : sig->getRequirements()) {
auto requirements = sig->getRequirements();
for (unsigned pos = 0, n = requirements.size(); pos != n; ++pos) {
const auto &req = requirements[pos];
Optional<Requirement> openedReq;
auto openedFirst = openType(req.getFirstType(), replacements);
@@ -1078,7 +1081,11 @@ void ConstraintSystem::openGeneric(
openedReq = Requirement(kind, openedFirst, req.getLayoutConstraint());
break;
}
addConstraint(*openedReq, locatorPtr);
addConstraint(
*openedReq,
locator.withPathElement(ConstraintLocator::OpenedGeneric)
.withPathElement(LocatorPathElt::getTypeRequirementComponent(pos)));
}
}