@@ -1615,38 +1615,46 @@ void ConstraintSystem::openGenericRequirements(
16151615 llvm::function_ref<Type(Type)> substFn) {
16161616 auto requirements = signature.getRequirements ();
16171617 for (unsigned pos = 0 , n = requirements.size (); pos != n; ++pos) {
1618- const auto &req = requirements[pos];
1619-
1620- Optional<Requirement> openedReq;
1621- auto openedFirst = substFn (req.getFirstType ());
1622-
1623- auto kind = req.getKind ();
1624- switch (kind) {
1625- case RequirementKind::Conformance: {
1626- auto protoDecl = req.getProtocolDecl ();
1627- // Determine whether this is the protocol 'Self' constraint we should
1628- // skip.
1629- if (skipProtocolSelfConstraint && protoDecl == outerDC &&
1630- protoDecl->getSelfInterfaceType ()->isEqual (req.getFirstType ()))
1631- continue ;
1632- openedReq = Requirement (kind, openedFirst, req.getSecondType ());
1633- break ;
1634- }
1635- case RequirementKind::Superclass:
1636- case RequirementKind::SameType:
1637- openedReq = Requirement (kind, openedFirst, substFn (req.getSecondType ()));
1638- break ;
1639- case RequirementKind::Layout:
1640- openedReq = Requirement (kind, openedFirst, req.getLayoutConstraint ());
1641- break ;
1642- }
1643-
16441618 auto openedGenericLoc =
1645- locator.withPathElement (LocatorPathElt::OpenedGeneric (signature));
1646- addConstraint (*openedReq,
1647- openedGenericLoc.withPathElement (
1648- LocatorPathElt::TypeParameterRequirement (pos, kind)));
1619+ locator.withPathElement (LocatorPathElt::OpenedGeneric (signature));
1620+ openGenericRequirement (outerDC, pos, requirements[pos],
1621+ skipProtocolSelfConstraint, openedGenericLoc,
1622+ substFn);
1623+ }
1624+ }
1625+
1626+ void ConstraintSystem::openGenericRequirement (
1627+ DeclContext *outerDC, unsigned index, const Requirement &req,
1628+ bool skipProtocolSelfConstraint, ConstraintLocatorBuilder locator,
1629+ llvm::function_ref<Type(Type)> substFn) {
1630+ Optional<Requirement> openedReq;
1631+ auto openedFirst = substFn (req.getFirstType ());
1632+
1633+ auto kind = req.getKind ();
1634+ switch (kind) {
1635+ case RequirementKind::Conformance: {
1636+ auto protoDecl = req.getProtocolDecl ();
1637+ // Determine whether this is the protocol 'Self' constraint we should
1638+ // skip.
1639+ if (skipProtocolSelfConstraint && protoDecl == outerDC &&
1640+ protoDecl->getSelfInterfaceType ()->isEqual (req.getFirstType ()))
1641+ return ;
1642+
1643+ openedReq = Requirement (kind, openedFirst, req.getSecondType ());
1644+ break ;
16491645 }
1646+ case RequirementKind::Superclass:
1647+ case RequirementKind::SameType:
1648+ openedReq = Requirement (kind, openedFirst, substFn (req.getSecondType ()));
1649+ break ;
1650+ case RequirementKind::Layout:
1651+ openedReq = Requirement (kind, openedFirst, req.getLayoutConstraint ());
1652+ break ;
1653+ }
1654+
1655+ addConstraint (*openedReq,
1656+ locator.withPathElement (
1657+ LocatorPathElt::TypeParameterRequirement (index, kind)));
16501658}
16511659
16521660// / Add the constraint on the type used for the 'Self' type for a member
0 commit comments