@@ -584,16 +584,15 @@ class PackTransformResultPlan final : public ResultPlan {
584
584
// / A result plan which produces a larger RValue from a bunch of
585
585
// / components.
586
586
class TupleRValueResultPlan final : public ResultPlan {
587
- CanTupleType substType;
588
-
587
+ CanType substType;
589
588
SmallVector<ResultPlanPtr, 4 > origEltPlans;
590
589
591
590
public:
592
591
TupleRValueResultPlan (ResultPlanBuilder &builder, AbstractionPattern origType,
593
- CanTupleType substType)
592
+ CanType substType)
594
593
: substType(substType) {
595
594
// Create plans for all the elements.
596
- origEltPlans.reserve (substType-> getNumElements ());
595
+ origEltPlans.reserve (origType. getNumTupleElements ());
597
596
origType.forEachTupleElement (substType,
598
597
[&](TupleElementGenerator &origElt) {
599
598
AbstractionPattern origEltType = origElt.getOrigType ();
@@ -643,7 +642,7 @@ class TupleInitializationResultPlan final : public ResultPlan {
643
642
TupleInitializationResultPlan (ResultPlanBuilder &builder,
644
643
Initialization *tupleInit,
645
644
AbstractionPattern origType,
646
- CanTupleType substType)
645
+ CanType substType)
647
646
: tupleInit(tupleInit) {
648
647
// Get the sub-initializations.
649
648
eltInits = tupleInit->splitIntoTupleElements (builder.SGF , builder.loc ,
@@ -1115,7 +1114,7 @@ ResultPlanPtr ResultPlanBuilder::build(Initialization *init,
1115
1114
CanType substType) {
1116
1115
// Destructure original tuples.
1117
1116
if (origType.isTuple ()) {
1118
- return buildForTuple (init, origType, cast<TupleType>( substType) );
1117
+ return buildForTuple (init, origType, substType);
1119
1118
}
1120
1119
1121
1120
assert (!origType.isPackExpansion () &&
@@ -1299,13 +1298,17 @@ ResultPlanBuilder::buildScalarIntoPack(SILValue packAddr,
1299
1298
1300
1299
ResultPlanPtr ResultPlanBuilder::buildForTuple (Initialization *init,
1301
1300
AbstractionPattern origType,
1302
- CanTupleType substType) {
1301
+ CanType substType) {
1303
1302
// If we have an initialization, and we can split it, do so.
1304
1303
if (init && init->canSplitIntoTupleElements ()) {
1305
1304
return ResultPlanPtr (
1306
1305
new TupleInitializationResultPlan (*this , init, origType, substType));
1307
1306
}
1308
1307
1308
+ auto substTupleType = dyn_cast<TupleType>(substType);
1309
+ bool substHasPackExpansion =
1310
+ (substTupleType && substTupleType.containsPackExpansionType ());
1311
+
1309
1312
// Otherwise, if the tuple contains a pack expansion, we'll need to
1310
1313
// initialize a single buffer one way or another: either we're giving
1311
1314
// this to RValue (which wants a single value for tuples with pack
@@ -1319,9 +1322,9 @@ ResultPlanPtr ResultPlanBuilder::buildForTuple(Initialization *init,
1319
1322
// do that if we're not using lowered addresses because we prefer to
1320
1323
// build tuples with scalar operations.
1321
1324
auto &substTL = SGF.getTypeLowering (substType);
1322
- assert (substTL.isAddressOnly () || !substType. containsPackExpansionType () );
1325
+ assert (substTL.isAddressOnly () || !substHasPackExpansion );
1323
1326
if (substTL.isAddressOnly () &&
1324
- (substType. containsPackExpansionType () ||
1327
+ (substHasPackExpansion ||
1325
1328
(init != nullptr && SGF.F .getConventions ().useLoweredAddresses ()))) {
1326
1329
// Create a temporary.
1327
1330
auto temporary = SGF.emitTemporary (loc, substTL);
0 commit comments