Skip to content

Commit 16b1034

Browse files
committed
Do a proper orig+subst walk of tuple expression elements in call
argument emission.
1 parent 0e7b7e5 commit 16b1034

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

lib/SILGen/SILGenApply.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3389,10 +3389,23 @@ class ArgEmitter {
33893389
// If the source expression is a tuple literal, we can break it
33903390
// up directly.
33913391
if (auto tuple = dyn_cast<TupleExpr>(e)) {
3392-
for (auto i : indices(tuple->getElements())) {
3393-
emit(tuple->getElement(i),
3394-
origParamType.getTupleElementType(i));
3395-
}
3392+
auto substTupleType =
3393+
cast<TupleType>(e->getType()->getCanonicalType());
3394+
origParamType.forEachTupleElement(substTupleType,
3395+
[&](unsigned origEltIndex, unsigned substEltIndex,
3396+
AbstractionPattern origEltType, CanType substEltType) {
3397+
emit(tuple->getElement(substEltIndex), origEltType);
3398+
},
3399+
[&](unsigned origEltIndex, unsigned substEltIndex,
3400+
AbstractionPattern origExpansionType,
3401+
CanTupleEltTypeArrayRef substEltTypes) {
3402+
SmallVector<ArgumentSource, 4> eltArgs;
3403+
eltArgs.reserve(substEltTypes.size());
3404+
for (auto i : range(substEltIndex, substEltTypes.size())) {
3405+
eltArgs.emplace_back(tuple->getElement(i));
3406+
}
3407+
emitPackArg(eltArgs, origExpansionType);
3408+
});
33963409
return;
33973410
}
33983411

0 commit comments

Comments
 (0)