Skip to content

Commit 786efd6

Browse files
committed
[TypeLowering] Fix lexicality check for tuples.
Use the new mechanism for looking into tuples that properly handles packs.
1 parent 7e0b218 commit 786efd6

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

lib/SIL/IR/TypeLowering.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2758,16 +2758,14 @@ bool TypeConverter::visitAggregateLeaves(
27582758
packIndex);
27592759
}
27602760
} else if (auto tupleTy = ty->getAs<TupleType>()) {
2761-
for (unsigned tupleIndex = 0, num = tupleTy->getNumElements();
2762-
tupleIndex < num; ++tupleIndex) {
2763-
auto origElementTy = origTy.getTupleElementType(tupleIndex);
2764-
auto substElementTy =
2765-
tupleTy->getElementType(tupleIndex)->getCanonicalType();
2766-
substElementTy =
2767-
computeLoweredRValueType(context, origElementTy, substElementTy);
2768-
insertIntoWorklist(substElementTy, origElementTy, nullptr,
2769-
tupleIndex);
2770-
}
2761+
unsigned tupleIndex = 0;
2762+
origTy.forEachExpandedTupleElement(
2763+
CanTupleType(tupleTy),
2764+
[&](auto origElementTy, auto substElementTy, auto element) {
2765+
insertIntoWorklist(substElementTy, origElementTy, nullptr,
2766+
tupleIndex);
2767+
++tupleIndex;
2768+
});
27712769
} else if (auto *decl = ty->getStructOrBoundGenericStruct()) {
27722770
for (auto *structField : decl->getStoredProperties()) {
27732771
auto subMap = ty->getContextSubstitutionMap(&M, decl);

0 commit comments

Comments
 (0)