@@ -3793,13 +3793,14 @@ struct TypeSimplifier {
3793
3793
}
3794
3794
3795
3795
if (auto expansion = dyn_cast<PackExpansionType>(type.getPointer ())) {
3796
+ auto patternType = expansion->getPatternType ();
3796
3797
// First, let's check whether pattern type has all of the type variables
3797
3798
// that represent packs resolved, otherwise we don't have enough information
3798
3799
// to flatten this pack expansion type.
3799
3800
//
3800
3801
// Note that we don't actually need to do deep transformation here
3801
3802
// because pack variables can only appear in structural positions.
3802
- if (expansion-> getPatternType () .findIf ([&](Type type) {
3803
+ if (patternType .findIf ([&](Type type) {
3803
3804
if (auto *typeVar = type->getAs <TypeVariableType>()) {
3804
3805
if (typeVar->getImpl ().canBindToPack ())
3805
3806
return GetFixedTypeFn (typeVar)->is <TypeVariableType>();
@@ -3813,6 +3814,12 @@ struct TypeSimplifier {
3813
3814
auto countType = expansion->getCountType ().transform (
3814
3815
TypeSimplifier (CS, GetFixedTypeFn));
3815
3816
3817
+ // If both pattern and count are resolves, let's just return
3818
+ // the pattern type for `transformWithPosition` to take care
3819
+ // of the rest.
3820
+ if (patternType->is <PackType>() && countType->is <PackType>())
3821
+ return patternType;
3822
+
3816
3823
if (auto countPack = countType->getAs <PackType>()) {
3817
3824
SmallVector<Type, 4 > elts;
3818
3825
ActivePackExpansions.push_back ({false , 0 });
0 commit comments