@@ -2191,43 +2191,35 @@ ManagedValue SILGenFunction::emitStringLiteral(SILLocation loc,
2191
2191
2192
2192
// / Count the number of SILParameterInfos that are needed in order to
2193
2193
// / pass the given argument.
2194
- static unsigned getFlattenedValueCount (AbstractionPattern origType,
2195
- CanType substType) {
2196
- // The count is always 1 unless the substituted type is a tuple.
2197
- auto substTuple = dyn_cast<TupleType>(substType);
2198
- if (!substTuple)
2199
- return 1 ;
2200
-
2201
- // If the original type is opaque, the count is 1 anyway.
2202
- if (origType.isTypeParameter ())
2194
+ static unsigned getFlattenedValueCount (AbstractionPattern origType) {
2195
+ // The count is always 1 unless the original type is a tuple.
2196
+ if (!origType.isTuple ())
2203
2197
return 1 ;
2204
2198
2205
- // Otherwise, add up the elements.
2199
+ // Add up the elements.
2206
2200
unsigned count = 0 ;
2207
- origType. forEachTupleElement (substTuple, [&](TupleElementGenerator & elt) {
2208
- // Expansion components turn into a single parameter.
2209
- if (elt.isOrigPackExpansion ()) {
2201
+ for ( auto elt : origType. getTupleElementTypes () ) {
2202
+ // Expansion components turn into a single pack parameter.
2203
+ if (elt.isPackExpansion ()) {
2210
2204
count++;
2211
2205
2212
2206
// Recursively expand scalar components.
2213
2207
} else {
2214
- count += getFlattenedValueCount (elt.getOrigType (),
2215
- elt.getSubstTypes ()[0 ]);
2208
+ count += getFlattenedValueCount (elt);
2216
2209
}
2217
- });
2210
+ }
2218
2211
return count;
2219
2212
}
2220
2213
2221
2214
// / Count the number of SILParameterInfos that are needed in order to
2222
2215
// / pass the given argument.
2223
2216
static unsigned getFlattenedValueCount (AbstractionPattern origType,
2224
- CanType substType,
2225
2217
ImportAsMemberStatus foreignSelf) {
2226
2218
// C functions imported as static methods don't consume any real arguments.
2227
2219
if (foreignSelf.isStatic ())
2228
2220
return 0 ;
2229
2221
2230
- return getFlattenedValueCount (origType, substType );
2222
+ return getFlattenedValueCount (origType);
2231
2223
}
2232
2224
2233
2225
namespace {
@@ -3195,7 +3187,6 @@ class ArgEmitter {
3195
3187
auto defArg = std::move (arg).asKnownDefaultArg ();
3196
3188
3197
3189
auto numParams = getFlattenedValueCount (origParamType,
3198
- substParamType,
3199
3190
ImportAsMemberStatus ());
3200
3191
DelayedArguments.emplace_back (defArg,
3201
3192
defArg->getDefaultArgsOwner (),
@@ -3576,7 +3567,7 @@ class ArgEmitter {
3576
3567
3577
3568
void emitExpandedBorrowed (Expr *arg, AbstractionPattern origParamType) {
3578
3569
CanType substArgType = arg->getType ()->getCanonicalType ();
3579
- auto count = getFlattenedValueCount (origParamType, substArgType );
3570
+ auto count = getFlattenedValueCount (origParamType);
3580
3571
auto claimedParams = claimNextParameters (count);
3581
3572
3582
3573
SILType loweredSubstArgType = SGF.getLoweredType (substArgType);
@@ -3626,7 +3617,7 @@ class ArgEmitter {
3626
3617
3627
3618
void emitExpandedConsumed (Expr *arg, AbstractionPattern origParamType) {
3628
3619
CanType substArgType = arg->getType ()->getCanonicalType ();
3629
- auto count = getFlattenedValueCount (origParamType, substArgType );
3620
+ auto count = getFlattenedValueCount (origParamType);
3630
3621
auto claimedParams = claimNextParameters (count);
3631
3622
3632
3623
SILType loweredSubstArgType = SGF.getLoweredType (substArgType);
@@ -4432,10 +4423,8 @@ struct ParamLowering {
4432
4423
if (substParam.isInOut ()) {
4433
4424
count += 1 ;
4434
4425
} else {
4435
- count += getFlattenedValueCount (
4436
- origParamType,
4437
- substParam.getParameterType ()->getCanonicalType (),
4438
- ImportAsMemberStatus ());
4426
+ count += getFlattenedValueCount (origParamType,
4427
+ ImportAsMemberStatus ());
4439
4428
}
4440
4429
}
4441
4430
}
0 commit comments