@@ -857,25 +857,7 @@ Type ConstraintSystem::openUnboundGenericType(GenericTypeDecl *decl,
857
857
result = DC->mapTypeIntoContext (result);
858
858
}
859
859
860
- return result.transform ([&](Type type) -> Type {
861
- // Although generic parameters are declared with just `each`
862
- // their interface types introduce a pack expansion which
863
- // means that the solver has to extact generic argument type
864
- // variable from Pack{repeat ...} and drop that structure to
865
- // make sure that generic argument gets inferred to a pack type.
866
- if (auto *packTy = type->getAs <PackType>()) {
867
- assert (packTy->getNumElements () == 1 );
868
- auto *expansion = packTy->getElementType (0 )->castTo <PackExpansionType>();
869
- auto *typeVar = expansion->getPatternType ()->castTo <TypeVariableType>();
870
- assert (typeVar->getImpl ().getGenericParameter () &&
871
- typeVar->getImpl ().canBindToPack ());
872
- return typeVar;
873
- }
874
-
875
- if (auto *expansion = dyn_cast<PackExpansionType>(type.getPointer ()))
876
- return openPackExpansionType (expansion, replacements, locator);
877
- return type;
878
- });
860
+ return result;
879
861
}
880
862
881
863
static void checkNestedTypeConstraints (ConstraintSystem &cs, Type type,
@@ -1024,18 +1006,6 @@ Type ConstraintSystem::openType(Type type, OpenedTypeMap &replacements,
1024
1006
}
1025
1007
}
1026
1008
1027
- // While opening variadic generic types that appear in other types
1028
- // we need to extract generic parameter from Pack{repeat ...} structure
1029
- // that gets introduced by the interface type, see
1030
- // \c openUnboundGenericType for more details.
1031
- if (auto *packTy = type->getAs <PackType>()) {
1032
- if (auto expansionTy = packTy->unwrapSingletonPackExpansion ()) {
1033
- auto patternTy = expansionTy->getPatternType ();
1034
- if (patternTy->isTypeParameter ())
1035
- return openType (patternTy, replacements, locator);
1036
- }
1037
- }
1038
-
1039
1009
if (auto *expansion = type->getAs <PackExpansionType>()) {
1040
1010
return openPackExpansionType (expansion, replacements, locator);
1041
1011
}
@@ -3987,6 +3957,14 @@ struct TypeSimplifier {
3987
3957
auto countType = expansion->getCountType ().transform (
3988
3958
TypeSimplifier (CS, GetFixedTypeFn));
3989
3959
3960
+ if (!countType->is <PackType>() &&
3961
+ !countType->is <PackArchetypeType>()) {
3962
+ SmallVector<Type, 2 > rootParameterPacks;
3963
+ countType->getTypeParameterPacks (rootParameterPacks);
3964
+ if (!rootParameterPacks.empty ())
3965
+ countType = rootParameterPacks[0 ];
3966
+ }
3967
+
3990
3968
// If both pattern and count are resolves, let's just return
3991
3969
// the pattern type for `transformWithPosition` to take care
3992
3970
// of the rest.
0 commit comments