@@ -8427,11 +8427,10 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
8427
8427
8428
8428
// We sometimes get a pack expansion type here.
8429
8429
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()));
8435
8434
8436
8435
return SolutionKind::Solved;
8437
8436
}
@@ -8625,17 +8624,27 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
8625
8624
return recordFix(fix) ? SolutionKind::Error : SolutionKind::Solved;
8626
8625
}
8627
8626
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
+ }
8632
8636
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
+ }
8639
8648
8640
8649
if (auto req = path.back().getAs<LocatorPathElt::AnyRequirement>()) {
8641
8650
// If this is a requirement associated with `Self` which is bound
0 commit comments