Skip to content

Commit 1edb9a4

Browse files
committed
AST: Add some assertions to PackType::get()
1 parent 935edc9 commit 1edb9a4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/AST/ASTContext.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3179,6 +3179,14 @@ PackType *PackType::get(const ASTContext &C, ArrayRef<Type> elements) {
31793179
RecursiveTypeProperties properties;
31803180
bool isCanonical = true;
31813181
for (Type eltTy : elements) {
3182+
assert(!eltTy->isTypeParameter() ||
3183+
!eltTy->getRootGenericParam()->isTypeSequence() &&
3184+
"Pack type parameter outside of a pack expansion");
3185+
assert(!eltTy->is<SequenceArchetypeType>() &&
3186+
"Pack type archetype outside of a pack expansion");
3187+
assert(!eltTy->is<PackType>() &&
3188+
"Cannot have pack directly inside another pack");
3189+
31823190
properties |= eltTy->getRecursiveProperties();
31833191
if (!eltTy->isCanonical())
31843192
isCanonical = false;

0 commit comments

Comments
 (0)