Skip to content

Commit b06a9dc

Browse files
committed
[NFC] Make it more convenient to create canonical PackTypes
1 parent 68df7e8 commit b06a9dc

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

include/swift/AST/Types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6740,6 +6740,8 @@ class PackType final : public TypeBase, public llvm::FoldingSetNode,
67406740
}
67416741
};
67426742
BEGIN_CAN_TYPE_WRAPPER(PackType, Type)
6743+
static CanPackType get(const ASTContext &ctx, ArrayRef<CanType> elements);
6744+
67436745
CanType getElementType(unsigned elementNo) const {
67446746
return CanType(getPointer()->getElementType(elementNo));
67456747
}

lib/AST/ASTContext.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3302,6 +3302,11 @@ PackType *PackType::getEmpty(const ASTContext &C) {
33023302
return cast<PackType>(CanType(C.TheEmptyPackType));
33033303
}
33043304

3305+
CanPackType CanPackType::get(const ASTContext &C, ArrayRef<CanType> elements) {
3306+
SmallVector<Type, 8> ncElements(elements.begin(), elements.end());
3307+
return CanPackType(PackType::get(C, ncElements));
3308+
}
3309+
33053310
PackType *PackType::get(const ASTContext &C, ArrayRef<Type> elements) {
33063311
RecursiveTypeProperties properties;
33073312
bool isCanonical = true;

0 commit comments

Comments
 (0)