@@ -8427,11 +8427,10 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
84278427
84288428 // We sometimes get a pack expansion type here.
84298429 if (auto *expansionType = type->getAs<PackExpansionType>()) {
8430- // FIXME: Locator
8431- addConstraint(ConstraintKind::ConformsTo,
8432- expansionType->getPatternType(),
8433- protocol->getDeclaredInterfaceType(),
8434- locator);
8430+ addConstraint(
8431+ ConstraintKind::ConformsTo, expansionType->getPatternType(),
8432+ protocol->getDeclaredInterfaceType(),
8433+ locator.withPathElement(LocatorPathElt::PackExpansionPattern()));
84358434
84368435 return SolutionKind::Solved;
84378436 }
@@ -8625,17 +8624,27 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
86258624 return recordFix(fix) ? SolutionKind::Error : SolutionKind::Solved;
86268625 }
86278626
8628- // If we have something like ... -> type req # -> pack element #, we're
8629- // solving a requirement of the form T : P where T is a type parameter pack
8630- if (path.back().is<LocatorPathElt::PackElement>())
8631- path.pop_back();
8627+ // Conditional conformance requirements could produce chains of
8628+ // `path element -> pack expansion pattern -> pack element`.
8629+ while (!path.empty()) {
8630+ // If we have something like ... -> type req # -> pack element #, we're
8631+ // solving a requirement of the form T : P where T is a type parameter pack
8632+ if (path.back().is<LocatorPathElt::PackElement>()) {
8633+ path.pop_back();
8634+ continue;
8635+ }
86328636
8633- // This is similar to `PackElement` but locator points to the requirement
8634- // associted with pack expansion pattern (i.e. `repeat each T: P`) where
8635- // the path is something like:
8636- // `... -> type req # -> pack expansion pattern`.
8637- if (path.back().is<LocatorPathElt::PackExpansionPattern>())
8638- path.pop_back();
8637+ // This is similar to `PackElement` but locator points to the requirement
8638+ // associated with pack expansion pattern (i.e. `repeat each T: P`) where
8639+ // the path is something like:
8640+ // `... -> type req # -> pack expansion pattern`.
8641+ if (path.back().is<LocatorPathElt::PackExpansionPattern>()) {
8642+ path.pop_back();
8643+ continue;
8644+ }
8645+
8646+ break;
8647+ }
86398648
86408649 if (auto req = path.back().getAs<LocatorPathElt::AnyRequirement>()) {
86418650 // If this is a requirement associated with `Self` which is bound
0 commit comments