Skip to content

Commit 77ac9db

Browse files
committed
[NFC] Add a function to induce a pack type from a slice of CanParams.
1 parent dc4b7db commit 77ac9db

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

include/swift/AST/Types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6866,6 +6866,8 @@ class PackType final : public TypeBase, public llvm::FoldingSetNode,
68666866
BEGIN_CAN_TYPE_WRAPPER(PackType, Type)
68676867
static CanPackType get(const ASTContext &ctx, ArrayRef<CanType> elements);
68686868
static CanPackType get(const ASTContext &ctx, CanTupleEltTypeArrayRef elts);
6869+
static CanPackType get(const ASTContext &ctx,
6870+
AnyFunctionType::CanParamArrayRef params);
68696871

68706872
static CanTypeWrapper<PackType>
68716873
getSingletonPackExpansion(CanType packParameter);

lib/AST/ASTContext.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3305,6 +3305,16 @@ CanPackType CanPackType::get(const ASTContext &C,
33053305
return CanPackType(PackType::get(C, ncElements));
33063306
}
33073307

3308+
CanPackType CanPackType::get(const ASTContext &C,
3309+
AnyFunctionType::CanParamArrayRef params) {
3310+
SmallVector<Type, 8> ncElements;
3311+
ncElements.reserve(params.size());
3312+
for (auto param : params) {
3313+
ncElements.push_back(param.getParameterType());
3314+
}
3315+
return CanPackType(PackType::get(C, ncElements));
3316+
}
3317+
33083318
PackType *PackType::get(const ASTContext &C, ArrayRef<Type> elements) {
33093319
RecursiveTypeProperties properties;
33103320
bool isCanonical = true;

0 commit comments

Comments
 (0)