Skip to content

Commit af14bba

Browse files
committed
[AST] Simplify AnyFunctionType::composeTuple
Remove the canonicalVararg parameter and CanParamArrayRef wrapper. Almost none of the callers want canonicalVararg, and the one that does calls `getCanonicalType` on the result anyway.
1 parent 8c43800 commit af14bba

File tree

8 files changed

+12
-27
lines changed

8 files changed

+12
-27
lines changed

include/swift/AST/Types.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3005,12 +3005,7 @@ class AnyFunctionType : public TypeBase {
30053005

30063006
public:
30073007
/// Take an array of parameters and turn it into a tuple or paren type.
3008-
static Type composeTuple(ASTContext &ctx, ArrayRef<Param> params,
3009-
bool canonicalVararg);
3010-
static Type composeTuple(ASTContext &ctx, CanParamArrayRef params,
3011-
bool canonicalVararg) {
3012-
return composeTuple(ctx, params.getOriginalArray(), canonicalVararg);
3013-
}
3008+
static Type composeTuple(ASTContext &ctx, ArrayRef<Param> params);
30143009

30153010
/// Given two arrays of parameters determine if they are equal in their
30163011
/// canonicalized form. Internal labels and type sugar is *not* taken into

lib/APIDigester/ModuleAnalyzerNodes.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,8 +1519,7 @@ SwiftDeclCollector::constructTypeNode(Type T, TypeInitInfo Info) {
15191519
Root->addChild(constructTypeNode(Fun->getResult()));
15201520

15211521
auto Input = AnyFunctionType::composeTuple(Fun->getASTContext(),
1522-
Fun->getParams(),
1523-
/*canonicalVararg=*/false);
1522+
Fun->getParams());
15241523
Root->addChild(constructTypeNode(Input));
15251524
return Root;
15261525
}

lib/AST/ASTContext.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3456,12 +3456,10 @@ Type AnyFunctionType::Param::getParameterType(bool forCanonical,
34563456
return type;
34573457
}
34583458

3459-
Type AnyFunctionType::composeTuple(ASTContext &ctx, ArrayRef<Param> params,
3460-
bool canonicalVararg) {
3459+
Type AnyFunctionType::composeTuple(ASTContext &ctx, ArrayRef<Param> params) {
34613460
SmallVector<TupleTypeElt, 4> elements;
34623461
for (const auto &param : params) {
3463-
Type eltType = param.getParameterType(canonicalVararg, &ctx);
3464-
elements.emplace_back(eltType, param.getLabel(),
3462+
elements.emplace_back(param.getParameterType(), param.getLabel(),
34653463
param.getParameterFlags());
34663464
}
34673465
return TupleType::get(elements, ctx);

lib/SILGen/SILGenApply.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4023,8 +4023,7 @@ RValue CallEmission::applyEnumElementConstructor(SGFContext C) {
40234023
std::move(*callSite).forward());
40244024

40254025
auto payloadTy = AnyFunctionType::composeTuple(SGF.getASTContext(),
4026-
resultFnType.getParams(),
4027-
/*canonicalVararg*/ true);
4026+
resultFnType->getParams());
40284027
auto arg = RValue(SGF, argVals, payloadTy->getCanonicalType());
40294028
payload = ArgumentSource(uncurriedLoc, std::move(arg));
40304029
formalResultType = cast<FunctionType>(formalResultType).getResult();

lib/SILGen/SILGenExpr.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2659,8 +2659,7 @@ loadIndexValuesForKeyPathComponent(SILGenFunction &SGF, SILLocation loc,
26592659

26602660
auto indexLoweredTy =
26612661
SGF.getLoweredType(
2662-
AnyFunctionType::composeTuple(SGF.getASTContext(), indexParams,
2663-
/*canonicalVararg=*/false));
2662+
AnyFunctionType::composeTuple(SGF.getASTContext(), indexParams));
26642663

26652664
auto addr = SGF.B.createPointerToAddress(loc, pointer,
26662665
indexLoweredTy.getAddressType(),

lib/Sema/CSSimplify.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2002,8 +2002,7 @@ static bool fixMissingArguments(ConstraintSystem &cs, ASTNode anchor,
20022002
// synthesized arguments to it.
20032003
if (argumentTuple) {
20042004
cs.addConstraint(ConstraintKind::Bind, *argumentTuple,
2005-
FunctionType::composeTuple(ctx, args,
2006-
/*canonicalVararg=*/false),
2005+
FunctionType::composeTuple(ctx, args),
20072006
cs.getConstraintLocator(anchor));
20082007
}
20092008

@@ -2218,8 +2217,7 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
22182217
};
22192218

22202219
auto implodeParams = [&](SmallVectorImpl<AnyFunctionType::Param> &params) {
2221-
auto input = AnyFunctionType::composeTuple(getASTContext(), params,
2222-
/*canonicalVararg=*/false);
2220+
auto input = AnyFunctionType::composeTuple(getASTContext(), params);
22232221

22242222
params.clear();
22252223
// If fixes are disabled let's do an easy thing and implode
@@ -6073,8 +6071,7 @@ ConstraintSystem::simplifyConstructionConstraint(
60736071

60746072
// Tuple construction is simply tuple conversion.
60756073
Type argType = AnyFunctionType::composeTuple(getASTContext(),
6076-
fnType->getParams(),
6077-
/*canonicalVararg=*/false);
6074+
fnType->getParams());
60786075
Type resultType = fnType->getResult();
60796076

60806077
ConstraintLocatorBuilder builder(locator);
@@ -7006,8 +7003,7 @@ ConstraintSystem::simplifyFunctionComponentConstraint(
70067003

70077004
if (kind == ConstraintKind::FunctionInput) {
70087005
type = AnyFunctionType::composeTuple(getASTContext(),
7009-
funcTy->getParams(),
7010-
/*canonicalVararg=*/false);
7006+
funcTy->getParams());
70117007
locKind = ConstraintLocator::FunctionArgument;
70127008
} else if (kind == ConstraintKind::FunctionResult) {
70137009
type = funcTy->getResult();

lib/Sema/TypeCheckDeclOverride.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ static bool noteFixableMismatchedTypes(ValueDecl *decl, const ValueDecl *base) {
482482
auto *fnType = baseTy->getAs<AnyFunctionType>();
483483
baseTy = fnType->getResult();
484484
Type argTy = FunctionType::composeTuple(
485-
ctx, baseTy->getAs<AnyFunctionType>()->getParams(), false);
485+
ctx, baseTy->getAs<AnyFunctionType>()->getParams());
486486
auto diagKind = diag::override_type_mismatch_with_fixits_init;
487487
unsigned numArgs = baseInit->getParameters()->size();
488488
return computeFixitsForOverridenDeclaration(

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2164,8 +2164,7 @@ static Type getTypeForDisplay(ModuleDecl *module, ValueDecl *decl) {
21642164
return AnyFunctionType::composeTuple(module->getASTContext(),
21652165
ctor->getMethodInterfaceType()
21662166
->castTo<FunctionType>()
2167-
->getParams(),
2168-
/*canonicalVararg=*/false);
2167+
->getParams());
21692168
}
21702169

21712170
Type type = decl->getInterfaceType();

0 commit comments

Comments
 (0)