@@ -2425,6 +2425,23 @@ ConstraintSystem::matchPackTypes(PackType *pack1, PackType *pack2,
24252425 return getTypeMatchSuccess();
24262426}
24272427
2428+ ConstraintSystem::TypeMatchResult
2429+ ConstraintSystem::matchPackExpansionTypes(PackExpansionType *expansion1,
2430+ PackExpansionType *expansion2,
2431+ ConstraintKind kind, TypeMatchOptions flags,
2432+ ConstraintLocatorBuilder locator) {
2433+ // FIXME: Should we downgrade kind to Bind or something here?
2434+ auto result = matchTypes(expansion1->getCountType(),
2435+ expansion2->getCountType(),
2436+ kind, flags, locator);
2437+ if (result.isFailure())
2438+ return result;
2439+
2440+ return matchTypes(expansion1->getPatternType(),
2441+ expansion2->getPatternType(),
2442+ kind, flags, locator);
2443+ }
2444+
24282445/// Check where a representation is a subtype of another.
24292446///
24302447/// The subtype relationship is defined as:
@@ -6636,10 +6653,13 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
66366653 kind, subflags, packLoc);
66376654 }
66386655 case TypeKind::PackExpansion: {
6639- // FIXME: we need to match the count types as well
6640- return matchTypes(cast<PackExpansionType>(desugar1)->getPatternType(),
6641- cast<PackExpansionType>(desugar2)->getPatternType(),
6642- kind, subflags, locator);
6656+ // FIXME: Need a new locator element
6657+
6658+ auto expansion1 = cast<PackExpansionType>(desugar1);
6659+ auto expansion2 = cast<PackExpansionType>(desugar2);
6660+
6661+ return matchPackExpansionTypes(expansion1, expansion2, kind, subflags,
6662+ locator);
66436663 }
66446664 }
66456665 }
@@ -7034,20 +7054,6 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
70347054 }
70357055 }
70367056
7037- if (isa<PackExpansionType>(desugar1) && isa<PackType>(desugar2)) {
7038- auto *packExpansionType = cast<PackExpansionType>(desugar1);
7039- auto *packType = cast<PackType>(desugar2);
7040-
7041- if (packExpansionType->getPatternType()->is<TypeVariableType>())
7042- return matchTypes(packExpansionType->getPatternType(), packType, kind, subflags, locator);
7043- } else if (isa<PackType>(desugar1) && isa<PackExpansionType>(desugar2)) {
7044- auto *packType = cast<PackType>(desugar1);
7045- auto *packExpansionType = cast<PackExpansionType>(desugar2);
7046-
7047- if (packExpansionType->getPatternType()->is<TypeVariableType>())
7048- return matchTypes(packType, packExpansionType->getPatternType(), kind, subflags, locator);
7049- }
7050-
70517057 // Attempt fixes iff it's allowed, both types are concrete and
70527058 // we are not in the middle of attempting one already.
70537059 if (shouldAttemptFixes() && !flags.contains(TMF_ApplyingFix)) {
0 commit comments