summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-ast-builder.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-ast-builder.cpp')
-rw-r--r--source/slang/slang-ast-builder.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/source/slang/slang-ast-builder.cpp b/source/slang/slang-ast-builder.cpp
index 3a2b2933d..a13e13851 100644
--- a/source/slang/slang-ast-builder.cpp
+++ b/source/slang/slang-ast-builder.cpp
@@ -572,9 +572,26 @@ Type* ASTBuilder::getExpandType(Type* pattern, ArrayView<Type*> capturedPacks)
return getOrCreate<ExpandType>(pattern, capturedPacks);
}
+void flattenTypeList(ShortList<Type*>& flattenedList, Type* type)
+{
+ if (auto typePack = as<ConcreteTypePack>(type))
+ {
+ for (Index i = 0; i < typePack->getTypeCount(); i++)
+ flattenTypeList(flattenedList, typePack->getElementType(i));
+ }
+ else
+ {
+ flattenedList.add(type);
+ }
+}
+
ConcreteTypePack* ASTBuilder::getTypePack(ArrayView<Type*> types)
{
- return getOrCreate<ConcreteTypePack>(types);
+ // Flatten all type packs in the type list.
+ ShortList<Type*> flattenedTypes;
+ for (auto type : types)
+ flattenTypeList(flattenedTypes, type);
+ return getOrCreate<ConcreteTypePack>(flattenedTypes.getArrayView().arrayView);
}
TypeEqualityWitness* ASTBuilder::getTypeEqualityWitness(