Skip to content

Commit c8a4939

Browse files
committed
SIL: Factor out shouldExpandParams() from DestructureInputs
I'm going to need this when emitting reabstraction thunks using the new function pointer representation.
1 parent 53ff62e commit c8a4939

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

include/swift/SIL/TypeLowering.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,20 @@ inline bool shouldExpandTupleType(TupleType *type) {
6464
return false;
6565
}
6666

67+
/// A version of the above for parameter lists.
68+
///
69+
/// FIXME: Should also remove this soon.
70+
inline bool shouldExpandParams(AnyFunctionType::CanParamArrayRef params) {
71+
for (auto param : params)
72+
if (param.getValueOwnership() != ValueOwnership::Default)
73+
return true;
74+
75+
if (params.size() == 1)
76+
return params[0].isVariadic();
77+
78+
return false;
79+
}
80+
6781
/// The default convention for handling the callee object on thick
6882
/// callees.
6983
const ParameterConvention DefaultThickCalleeConvention =

lib/SIL/SILFunctionType.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -608,13 +608,7 @@ class DestructureInputs {
608608
// If the abstraction pattern is opaque and the parameter list is a valid
609609
// target for substitution, implode it into a single tuple parameter.
610610
if (!hasSelf) {
611-
bool canImplode = true;
612-
for (auto param : params)
613-
canImplode &= (param.getValueOwnership() == ValueOwnership::Default);
614-
if (params.size() == 1)
615-
canImplode &= !params[0].isVariadic();
616-
617-
if (canImplode && origType.isTypeParameter()) {
611+
if (origType.isTypeParameter() && !shouldExpandParams(params)) {
618612
CanType ty = AnyFunctionType::composeInput(M.getASTContext(), params,
619613
/*canonicalVararg*/true)
620614
->getCanonicalType();

0 commit comments

Comments
 (0)