@@ -247,13 +247,13 @@ createGenericParam(ASTContext &ctx, const char *name, unsigned index,
247
247
// / Create a generic parameter list with multiple generic parameters.
248
248
static GenericParamList *getGenericParams (ASTContext &ctx,
249
249
unsigned numParameters,
250
- bool areParametersPacks = false ) {
250
+ bool areParameterPacks = false ) {
251
251
assert (numParameters <= std::size (GenericParamNames));
252
252
253
253
SmallVector<GenericTypeParamDecl *, 2 > genericParams;
254
254
for (unsigned i = 0 ; i != numParameters; ++i)
255
255
genericParams.push_back (createGenericParam (ctx, GenericParamNames[i], i,
256
- areParametersPacks ));
256
+ areParameterPacks ));
257
257
258
258
auto paramList = GenericParamList::create (ctx, SourceLoc (), genericParams,
259
259
SourceLoc ());
@@ -754,16 +754,9 @@ namespace {
754
754
};
755
755
struct ParameterGenerator {
756
756
unsigned Index;
757
- bool isPackExpansion;
758
757
Type build (BuiltinFunctionBuilder &builder) const {
759
- auto ty = builder.TheGenericParamList ->getParams ()[Index]
758
+ return builder.TheGenericParamList ->getParams ()[Index]
760
759
->getDeclaredInterfaceType ();
761
-
762
- if (isPackExpansion) {
763
- return PackExpansionType::get (ty, ty);
764
- }
765
-
766
- return ty;
767
760
}
768
761
};
769
762
struct LambdaGenerator {
@@ -780,6 +773,15 @@ namespace {
780
773
return MetatypeType::get (Object.build (builder), Repr);
781
774
}
782
775
};
776
+ struct ParameterPackGenerator {
777
+ unsigned Index;
778
+ Type build (BuiltinFunctionBuilder &builder) const {
779
+ auto ty = builder.TheGenericParamList ->getParams ()[Index]
780
+ ->getDeclaredInterfaceType ();
781
+
782
+ return PackExpansionType::get (ty, ty);
783
+ }
784
+ };
783
785
};
784
786
} // end anonymous namespace
785
787
@@ -789,8 +791,8 @@ makeConcrete(Type type) {
789
791
}
790
792
791
793
static BuiltinFunctionBuilder::ParameterGenerator
792
- makeGenericParam (unsigned index = 0 , bool isPackExpansion = false ) {
793
- return { index, isPackExpansion };
794
+ makeGenericParam (unsigned index = 0 ) {
795
+ return { index };
794
796
}
795
797
796
798
template <class ... Gs>
@@ -827,6 +829,11 @@ makeMetatype(const T &object,
827
829
return { object, repr };
828
830
}
829
831
832
+ static BuiltinFunctionBuilder::ParameterPackGenerator
833
+ makeParameterPack (unsigned index = 0 ) {
834
+ return { index };
835
+ }
836
+
830
837
// / Create a function with type <T> T -> ().
831
838
static ValueDecl *getRefCountingOperation (ASTContext &ctx, Identifier id) {
832
839
return getBuiltinFunction (ctx, id, _thin,
@@ -1952,8 +1959,7 @@ static ValueDecl *getPackCount(ASTContext &ctx, Identifier id) {
1952
1959
/* anyObject */ false ,
1953
1960
/* areParametersPack */ true );
1954
1961
1955
- auto packEx = makeGenericParam (/* index */ 0 , /* isPackExpansion */ true );
1956
- auto paramTy = makeMetatype (makeTuple (packEx));
1962
+ auto paramTy = makeMetatype (makeTuple (makeParameterPack ()));
1957
1963
builder.addParameter (paramTy);
1958
1964
builder.setResult (makeConcrete (BuiltinIntegerType::getWordType (ctx)));
1959
1965
0 commit comments