Skip to content

Commit 40e49e5

Browse files
committed
Sema: Replace trivial FunctionType::getOld() with decomposeInput()
These usages of getOld() always pass in a ParenType or TupleType as the input type, so there's no conceptual difficulty with using the new representation instead. Note that eventually we want to remove decomposeInput() too. However until ApplyExpr and friends are redesigned to directly hold multiple arguments instead of a single argument sub-expression that is a ParenExpr or TupleExpr, we don't have a good way to avoid building a tuple type and decomposing it in this one case. Instead just inline what getOld() does so we can move forward.
1 parent e77d46f commit 40e49e5

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

lib/Sema/CSGen.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,9 +1530,16 @@ namespace {
15301530
CS.getConstraintLocator(expr, ConstraintLocator::RValueAdjustment));
15311531

15321532
// The function/enum case must be callable with the given argument.
1533-
auto funcTy = FunctionType::getOld(CS.getType(arg), outputTy);
1534-
CS.addConstraint(ConstraintKind::ApplicableFunction, funcTy,
1535-
memberTy,
1533+
1534+
// FIXME: Redesign the AST so that an UnresolvedMemberExpr directly
1535+
// stores a list of arguments together with their inout-ness, instead of
1536+
// a single ParenExpr or TupleExpr argument.
1537+
SmallVector<AnyFunctionType::Param, 8> params;
1538+
AnyFunctionType::decomposeInput(CS.getType(arg), params);
1539+
1540+
CS.addConstraint(ConstraintKind::ApplicableFunction,
1541+
FunctionType::get(params, outputTy),
1542+
memberTy,
15361543
CS.getConstraintLocator(expr, ConstraintLocator::ApplyFunction));
15371544

15381545
return baseTy;
@@ -2530,11 +2537,15 @@ namespace {
25302537
FunctionType::ExtInfo extInfo;
25312538
if (isa<ClosureExpr>(fnExpr->getSemanticsProvidingExpr()))
25322539
extInfo = extInfo.withNoEscape();
2533-
2534-
auto funcTy = FunctionType::getOld(CS.getType(expr->getArg()), outputTy,
2535-
extInfo);
25362540

2537-
CS.addConstraint(ConstraintKind::ApplicableFunction, funcTy,
2541+
// FIXME: Redesign the AST so that an ApplyExpr directly stores a list of
2542+
// arguments together with their inout-ness, instead of a single
2543+
// ParenExpr or TupleExpr.
2544+
SmallVector<AnyFunctionType::Param, 8> params;
2545+
AnyFunctionType::decomposeInput(CS.getType(expr->getArg()), params);
2546+
2547+
CS.addConstraint(ConstraintKind::ApplicableFunction,
2548+
FunctionType::get(params, outputTy, extInfo),
25382549
CS.getType(expr->getFn()),
25392550
CS.getConstraintLocator(expr, ConstraintLocator::ApplyFunction));
25402551

0 commit comments

Comments
 (0)