Skip to content

Commit 6c1642f

Browse files
committed
[AST] Added hasConcretePack recursive property.
1 parent 4cf7dda commit 6c1642f

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

include/swift/AST/Types.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,10 @@ class RecursiveTypeProperties {
173173
/// This type contains an ElementArchetype.
174174
HasElementArchetype = 0x4000,
175175

176-
Last_Property = HasElementArchetype
176+
/// This type contains a concrete pack.
177+
HasConcretePack = 0x8000,
178+
179+
Last_Property = HasConcretePack
177180
};
178181
enum { BitWidth = countBitsUsed(Property::Last_Property) };
179182

@@ -243,6 +246,8 @@ class RecursiveTypeProperties {
243246

244247
bool hasParameterPack() const { return Bits & HasParameterPack; }
245248

249+
bool hasConcretePack() const { return Bits & HasConcretePack; }
250+
246251
/// Does a type with these properties structurally contain a
247252
/// parameterized existential type?
248253
bool hasParameterizedExistential() const {
@@ -670,6 +675,13 @@ class alignas(1 << TypeAlignInBits) TypeBase
670675
return getRecursiveProperties().hasParameterPack();
671676
}
672677

678+
bool hasConcretePack() const {
679+
return getRecursiveProperties().hasConcretePack();
680+
}
681+
682+
/// Whether the type has some flavor of pack.
683+
bool hasPack() const { return hasParameterPack() || hasConcretePack(); }
684+
673685
/// Determine whether the type involves a parameterized existential type.
674686
bool hasParameterizedExistential() const {
675687
return getRecursiveProperties().hasParameterizedExistential();

lib/AST/ASTContext.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3312,7 +3312,7 @@ CanPackType CanPackType::get(const ASTContext &C,
33123312
}
33133313

33143314
PackType *PackType::get(const ASTContext &C, ArrayRef<Type> elements) {
3315-
RecursiveTypeProperties properties;
3315+
RecursiveTypeProperties properties = RecursiveTypeProperties::HasConcretePack;
33163316
bool isCanonical = true;
33173317
for (Type eltTy : elements) {
33183318
assert(!eltTy->is<PackType>() &&
@@ -3352,7 +3352,7 @@ void PackType::Profile(llvm::FoldingSetNodeID &ID, ArrayRef<Type> Elements) {
33523352

33533353
CanSILPackType SILPackType::get(const ASTContext &C, ExtInfo info,
33543354
ArrayRef<CanType> elements) {
3355-
RecursiveTypeProperties properties;
3355+
RecursiveTypeProperties properties = RecursiveTypeProperties::HasConcretePack;
33563356
for (CanType eltTy : elements) {
33573357
assert(!isa<SILPackType>(eltTy) &&
33583358
"Cannot have pack directly inside another pack");
@@ -3944,7 +3944,7 @@ isAnyFunctionTypeCanonical(ArrayRef<AnyFunctionType::Param> params,
39443944
static RecursiveTypeProperties
39453945
getGenericFunctionRecursiveProperties(ArrayRef<AnyFunctionType::Param> params,
39463946
Type result) {
3947-
static_assert(RecursiveTypeProperties::BitWidth == 15,
3947+
static_assert(RecursiveTypeProperties::BitWidth == 16,
39483948
"revisit this if you add new recursive type properties");
39493949
RecursiveTypeProperties properties;
39503950

@@ -4604,7 +4604,7 @@ CanSILFunctionType SILFunctionType::get(
46044604
void *mem = ctx.Allocate(bytes, alignof(SILFunctionType));
46054605

46064606
RecursiveTypeProperties properties;
4607-
static_assert(RecursiveTypeProperties::BitWidth == 15,
4607+
static_assert(RecursiveTypeProperties::BitWidth == 16,
46084608
"revisit this if you add new recursive type properties");
46094609
for (auto &param : params)
46104610
properties |= param.getInterfaceType()->getRecursiveProperties();

0 commit comments

Comments
 (0)