@@ -2425,6 +2425,23 @@ ConstraintSystem::matchPackTypes(PackType *pack1, PackType *pack2,
2425
2425
return getTypeMatchSuccess();
2426
2426
}
2427
2427
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
+
2428
2445
/// Check where a representation is a subtype of another.
2429
2446
///
2430
2447
/// The subtype relationship is defined as:
@@ -6636,10 +6653,13 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
6636
6653
kind, subflags, packLoc);
6637
6654
}
6638
6655
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);
6643
6663
}
6644
6664
}
6645
6665
}
@@ -7034,20 +7054,6 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
7034
7054
}
7035
7055
}
7036
7056
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
-
7051
7057
// Attempt fixes iff it's allowed, both types are concrete and
7052
7058
// we are not in the middle of attempting one already.
7053
7059
if (shouldAttemptFixes() && !flags.contains(TMF_ApplyingFix)) {
0 commit comments