Skip to content

Commit df566e3

Browse files
committed
[AST] Rename decomposeInput/composeInput
Explicitly call out the fact we're dealing with tuples.
1 parent 7055988 commit df566e3

File tree

13 files changed

+33
-36
lines changed

13 files changed

+33
-36
lines changed

include/swift/AST/Types.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3018,19 +3018,16 @@ class AnyFunctionType : public TypeBase {
30183018
}
30193019

30203020
public:
3021-
/// Break an input type into an array of \c AnyFunctionType::Params.
3022-
static void decomposeInput(Type type,
3021+
/// Break a tuple or paren type into an array of \c AnyFunctionType::Params.
3022+
static void decomposeTuple(Type type,
30233023
SmallVectorImpl<Param> &result);
30243024

3025-
/// Take an array of parameters and turn it into an input type.
3026-
///
3027-
/// The result type is only there as a way to extract the ASTContext when
3028-
/// needed.
3029-
static Type composeInput(ASTContext &ctx, ArrayRef<Param> params,
3025+
/// Take an array of parameters and turn it into a tuple or paren type.
3026+
static Type composeTuple(ASTContext &ctx, ArrayRef<Param> params,
30303027
bool canonicalVararg);
3031-
static Type composeInput(ASTContext &ctx, CanParamArrayRef params,
3028+
static Type composeTuple(ASTContext &ctx, CanParamArrayRef params,
30323029
bool canonicalVararg) {
3033-
return composeInput(ctx, params.getOriginalArray(), canonicalVararg);
3030+
return composeTuple(ctx, params.getOriginalArray(), canonicalVararg);
30343031
}
30353032

30363033
/// Given two arrays of parameters determine if they are equal in their

lib/APIDigester/ModuleAnalyzerNodes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1500,7 +1500,7 @@ SwiftDeclCollector::constructTypeNode(Type T, TypeInitInfo Info) {
15001500
// Still, return type first
15011501
Root->addChild(constructTypeNode(Fun->getResult()));
15021502

1503-
auto Input = AnyFunctionType::composeInput(Fun->getASTContext(),
1503+
auto Input = AnyFunctionType::composeTuple(Fun->getASTContext(),
15041504
Fun->getParams(),
15051505
/*canonicalVararg=*/false);
15061506
Root->addChild(constructTypeNode(Input));

lib/AST/ASTContext.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3317,7 +3317,7 @@ AnyFunctionType *AnyFunctionType::withExtInfo(ExtInfo info) const {
33173317
getParams(), getResult(), info);
33183318
}
33193319

3320-
void AnyFunctionType::decomposeInput(
3320+
void AnyFunctionType::decomposeTuple(
33213321
Type type, SmallVectorImpl<AnyFunctionType::Param> &result) {
33223322
switch (type->getKind()) {
33233323
case TypeKind::Tuple: {
@@ -3366,7 +3366,7 @@ Type AnyFunctionType::Param::getParameterType(bool forCanonical,
33663366
return type;
33673367
}
33683368

3369-
Type AnyFunctionType::composeInput(ASTContext &ctx, ArrayRef<Param> params,
3369+
Type AnyFunctionType::composeTuple(ASTContext &ctx, ArrayRef<Param> params,
33703370
bool canonicalVararg) {
33713371
SmallVector<TupleTypeElt, 4> elements;
33723372
for (const auto &param : params) {

lib/AST/ASTVerifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1800,7 +1800,7 @@ class Verifier : public ASTWalker {
18001800

18011801
SmallVector<AnyFunctionType::Param, 8> Args;
18021802
Type InputExprTy = E->getArg()->getType();
1803-
AnyFunctionType::decomposeInput(InputExprTy, Args);
1803+
AnyFunctionType::decomposeTuple(InputExprTy, Args);
18041804
auto Params = FT->getParams();
18051805
if (!equalParamsIgnoringIsolation(Args, Params)) {
18061806
Out << "Argument type does not match parameter type in ApplyExpr:"

lib/SILGen/SILGenApply.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4022,7 +4022,7 @@ RValue CallEmission::applyEnumElementConstructor(SGFContext C) {
40224022
resultFnType, argVals,
40234023
std::move(*callSite).forward());
40244024

4025-
auto payloadTy = AnyFunctionType::composeInput(SGF.getASTContext(),
4025+
auto payloadTy = AnyFunctionType::composeTuple(SGF.getASTContext(),
40264026
resultFnType.getParams(),
40274027
/*canonicalVararg*/ true);
40284028
auto arg = RValue(SGF, argVals, payloadTy->getCanonicalType());
@@ -4278,7 +4278,7 @@ CallEmission CallEmission::forApplyExpr(SILGenFunction &SGF, ApplyExpr *e) {
42784278
Expr *arg = apply.callSite->getArg();
42794279

42804280
SmallVector<AnyFunctionType::Param, 8> params;
4281-
AnyFunctionType::decomposeInput(arg->getType(), params);
4281+
AnyFunctionType::decomposeTuple(arg->getType(), params);
42824282

42834283
PreparedArguments preparedArgs(params, arg);
42844284

lib/SILGen/SILGenExpr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2658,7 +2658,7 @@ loadIndexValuesForKeyPathComponent(SILGenFunction &SGF, SILLocation loc,
26582658

26592659
auto indexLoweredTy =
26602660
SGF.getLoweredType(
2661-
AnyFunctionType::composeInput(SGF.getASTContext(), indexParams,
2661+
AnyFunctionType::composeTuple(SGF.getASTContext(), indexParams,
26622662
/*canonicalVararg=*/false));
26632663

26642664
auto addr = SGF.B.createPointerToAddress(loc, pointer,

lib/SILGen/SILGenPoly.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ namespace {
923923
auto outputOrigType = AbstractionPattern::getTuple(outputOrigTypes);
924924

925925
// Build the substituted output tuple type. Note that we deliberately
926-
// don't use composeInput() because we want to drop ownership
926+
// don't use composeTuple() because we want to drop ownership
927927
// qualifiers.
928928
SmallVector<TupleTypeElt, 8> elts;
929929
for (auto param : outputSubstTypes) {

lib/Sema/CSApply.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,7 +1254,7 @@ namespace {
12541254
/*implicit=*/true);
12551255
}
12561256

1257-
auto argTy = AnyFunctionType::composeInput(context, calleeParams,
1257+
auto argTy = AnyFunctionType::composeTuple(context, calleeParams,
12581258
/*canonical*/false);
12591259
closureArg->setType(argTy);
12601260
cs.cacheType(closureArg);
@@ -5808,7 +5808,7 @@ Expr *ExprRewriter::coerceCallArguments(
58085808
ParameterListInfo paramInfo(params, callee.getDecl(), skipCurriedSelf);
58095809

58105810
SmallVector<AnyFunctionType::Param, 8> args;
5811-
AnyFunctionType::decomposeInput(cs.getType(arg), args);
5811+
AnyFunctionType::decomposeTuple(cs.getType(arg), args);
58125812

58135813
// If this application is an init(wrappedValue:) call that needs an injected
58145814
// wrapped value placeholder, the first non-defaulted argument must be
@@ -6101,7 +6101,7 @@ Expr *ExprRewriter::coerceCallArguments(
61016101
}
61026102

61036103
// Rebuild the argument list, sharing as much structure as possible.
6104-
auto paramType = AnyFunctionType::composeInput(ctx, newParams,
6104+
auto paramType = AnyFunctionType::composeTuple(ctx, newParams,
61056105
/*canonicalVararg=*/false);
61066106
if (isa<ParenType>(paramType.getPointer())) {
61076107
if (argParen) {
@@ -7639,7 +7639,7 @@ Expr *ExprRewriter::finishApply(ApplyExpr *apply, Type openedType,
76397639
{escapable}, {}, getType);
76407640
cs.cacheSubExprTypes(callSubExpr);
76417641
cs.setType(callSubExpr->getArg(),
7642-
AnyFunctionType::composeInput(ctx,
7642+
AnyFunctionType::composeTuple(ctx,
76437643
escapableParams, false));
76447644
cs.setType(callSubExpr, resultType);
76457645

lib/Sema/CSGen.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ namespace {
559559
if (!fnTy)
560560
return false;
561561

562-
Type paramTy = FunctionType::composeInput(CS.getASTContext(),
562+
Type paramTy = FunctionType::composeTuple(CS.getASTContext(),
563563
fnTy->getParams(), false);
564564

565565
auto argTy = CS.getType(expr->getArg())
@@ -637,7 +637,7 @@ namespace {
637637
return false;
638638

639639
auto paramTy =
640-
AnyFunctionType::composeInput(CS.getASTContext(), fnTy->getParams(),
640+
AnyFunctionType::composeTuple(CS.getASTContext(), fnTy->getParams(),
641641
/*canonicalVararg*/ false);
642642
return favoredTy->isEqual(paramTy);
643643
};
@@ -990,7 +990,7 @@ namespace {
990990
// arguments together with their inout-ness, instead of a single
991991
// ParenExpr or TupleExpr.
992992
SmallVector<AnyFunctionType::Param, 8> params;
993-
AnyFunctionType::decomposeInput(CS.getType(index), params);
993+
AnyFunctionType::decomposeTuple(CS.getType(index), params);
994994

995995
// Add the constraint that the index expression's type be convertible
996996
// to the input type of the subscript operator.
@@ -1211,7 +1211,7 @@ namespace {
12111211
FunctionRefKind::DoubleApply, {}, memberLoc);
12121212

12131213
SmallVector<AnyFunctionType::Param, 8> args;
1214-
AnyFunctionType::decomposeInput(CS.getType(expr->getArg()), args);
1214+
AnyFunctionType::decomposeTuple(CS.getType(expr->getArg()), args);
12151215

12161216
auto resultType = CS.createTypeVariable(
12171217
CS.getConstraintLocator(expr, ConstraintLocator::FunctionResult),
@@ -2264,7 +2264,7 @@ namespace {
22642264
// types so long as we have the right number of such types.
22652265
SmallVector<AnyFunctionType::Param, 4> externalEltTypes;
22662266
if (externalPatternType) {
2267-
AnyFunctionType::decomposeInput(externalPatternType,
2267+
AnyFunctionType::decomposeTuple(externalPatternType,
22682268
externalEltTypes);
22692269

22702270
// If we have the wrong number of elements, we may not be able to
@@ -2449,7 +2449,7 @@ namespace {
24492449
return Type();
24502450

24512451
SmallVector<AnyFunctionType::Param, 4> params;
2452-
AnyFunctionType::decomposeInput(subPatternType, params);
2452+
AnyFunctionType::decomposeTuple(subPatternType, params);
24532453

24542454
// Remove parameter labels; they aren't used when matching cases,
24552455
// but outright conflicts will be checked during coercion.
@@ -2681,7 +2681,7 @@ namespace {
26812681
// arguments together with their inout-ness, instead of a single
26822682
// ParenExpr or TupleExpr.
26832683
SmallVector<AnyFunctionType::Param, 8> params;
2684-
AnyFunctionType::decomposeInput(CS.getType(expr->getArg()), params);
2684+
AnyFunctionType::decomposeTuple(CS.getType(expr->getArg()), params);
26852685

26862686
CS.addConstraint(ConstraintKind::ApplicableFunction,
26872687
FunctionType::get(params, resultType, extInfo),

lib/Sema/CSSimplify.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2006,7 +2006,7 @@ static bool fixMissingArguments(ConstraintSystem &cs, ASTNode anchor,
20062006
// synthesized arguments to it.
20072007
if (argumentTuple) {
20082008
cs.addConstraint(ConstraintKind::Bind, *argumentTuple,
2009-
FunctionType::composeInput(ctx, args,
2009+
FunctionType::composeTuple(ctx, args,
20102010
/*canonicalVararg=*/false),
20112011
cs.getConstraintLocator(anchor));
20122012
}
@@ -2223,7 +2223,7 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
22232223
};
22242224

22252225
auto implodeParams = [&](SmallVectorImpl<AnyFunctionType::Param> &params) {
2226-
auto input = AnyFunctionType::composeInput(getASTContext(), params,
2226+
auto input = AnyFunctionType::composeTuple(getASTContext(), params,
22272227
/*canonicalVararg=*/false);
22282228

22292229
params.clear();
@@ -6028,7 +6028,7 @@ ConstraintSystem::simplifyConstructionConstraint(
60286028
}
60296029

60306030
// Tuple construction is simply tuple conversion.
6031-
Type argType = AnyFunctionType::composeInput(getASTContext(),
6031+
Type argType = AnyFunctionType::composeTuple(getASTContext(),
60326032
fnType->getParams(),
60336033
/*canonicalVararg=*/false);
60346034
Type resultType = fnType->getResult();
@@ -6945,7 +6945,7 @@ ConstraintSystem::simplifyFunctionComponentConstraint(
69456945
ConstraintLocator::PathElementKind locKind;
69466946

69476947
if (kind == ConstraintKind::FunctionInput) {
6948-
type = AnyFunctionType::composeInput(getASTContext(),
6948+
type = AnyFunctionType::composeTuple(getASTContext(),
69496949
funcTy->getParams(),
69506950
/*canonicalVararg=*/false);
69516951
locKind = ConstraintLocator::FunctionArgument;
@@ -7360,7 +7360,7 @@ performMemberLookup(ConstraintKind constraintKind, DeclNameRef memberName,
73607360
if (!ctor->isGenericContext()) {
73617361
auto args = ctor->getMethodInterfaceType()
73627362
->castTo<FunctionType>()->getParams();
7363-
auto argType = AnyFunctionType::composeInput(getASTContext(), args,
7363+
auto argType = AnyFunctionType::composeTuple(getASTContext(), args,
73647364
/*canonicalVarargs=*/false);
73657365
if (argType->isEqual(favoredType))
73667366
if (!isDeclUnavailable(decl, memberLocator))

lib/Sema/CodeSynthesis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ Expr *swift::buildArgumentForwardingExpr(ArrayRef<ParamDecl*> params,
136136
SourceLoc(), false, IsImplicit);
137137
}
138138

139-
auto argTy = AnyFunctionType::composeInput(ctx, elts, /*canonical*/false);
139+
auto argTy = AnyFunctionType::composeTuple(ctx, elts, /*canonical*/false);
140140
argExpr->setType(argTy);
141141

142142
return argExpr;

lib/Sema/TypeCheckDeclOverride.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ static bool noteFixableMismatchedTypes(ValueDecl *decl, const ValueDecl *base) {
463463
// input arguments.
464464
auto *fnType = baseTy->getAs<AnyFunctionType>();
465465
baseTy = fnType->getResult();
466-
Type argTy = FunctionType::composeInput(
466+
Type argTy = FunctionType::composeTuple(
467467
ctx, baseTy->getAs<AnyFunctionType>()->getParams(), false);
468468
auto diagKind = diag::override_type_mismatch_with_fixits_init;
469469
unsigned numArgs = baseInit->getParameters()->size();

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2161,7 +2161,7 @@ static void addAssocTypeDeductionString(llvm::SmallString<128> &str,
21612161
static Type getTypeForDisplay(ModuleDecl *module, ValueDecl *decl) {
21622162
// For a constructor, we only care about the parameter types.
21632163
if (auto ctor = dyn_cast<ConstructorDecl>(decl)) {
2164-
return AnyFunctionType::composeInput(module->getASTContext(),
2164+
return AnyFunctionType::composeTuple(module->getASTContext(),
21652165
ctor->getMethodInterfaceType()
21662166
->castTo<FunctionType>()
21672167
->getParams(),

0 commit comments

Comments
 (0)