@@ -583,7 +583,7 @@ struct SelectedOverload {
583583// / Provides information about the application of a function argument to a
584584// / parameter.
585585class FunctionArgApplyInfo {
586- Expr *ArgListExpr ;
586+ ArgumentList *ArgList ;
587587 Expr *ArgExpr;
588588 unsigned ArgIdx;
589589 Type ArgType;
@@ -595,15 +595,15 @@ class FunctionArgApplyInfo {
595595 const ValueDecl *Callee;
596596
597597public:
598- FunctionArgApplyInfo (Expr *argListExpr , Expr *argExpr, unsigned argIdx,
598+ FunctionArgApplyInfo (ArgumentList *argList , Expr *argExpr, unsigned argIdx,
599599 Type argType, unsigned paramIdx, Type fnInterfaceType,
600600 FunctionType *fnType, const ValueDecl *callee)
601- : ArgListExpr(argListExpr ), ArgExpr(argExpr), ArgIdx(argIdx),
602- ArgType (argType), ParamIdx(paramIdx), FnInterfaceType(fnInterfaceType),
603- FnType(fnType), Callee(callee) {}
601+ : ArgList(argList ), ArgExpr(argExpr), ArgIdx(argIdx), ArgType(argType ),
602+ ParamIdx (paramIdx), FnInterfaceType(fnInterfaceType), FnType(fnType ),
603+ Callee(callee) {}
604604
605605 // / \returns The list of the arguments used for this application.
606- Expr * getArgListExpr () const { return ArgListExpr ; }
606+ ArgumentList * getArgList () const { return ArgList ; }
607607
608608 // / \returns The argument being applied.
609609 Expr *getArgExpr () const { return ArgExpr; }
@@ -625,11 +625,7 @@ class FunctionArgApplyInfo {
625625
626626 // / \returns The label for the argument being applied.
627627 Identifier getArgLabel () const {
628- if (auto *te = dyn_cast<TupleExpr>(ArgListExpr))
629- return te->getElementName (ArgIdx);
630-
631- assert (isa<ParenExpr>(ArgListExpr));
632- return Identifier ();
628+ return ArgList->getLabel (ArgIdx);
633629 }
634630
635631 Identifier getParamLabel () const {
@@ -649,10 +645,8 @@ class FunctionArgApplyInfo {
649645 if (argLabel.empty ())
650646 return false ;
651647
652- if (auto *te = dyn_cast<TupleExpr>(ArgListExpr))
653- return llvm::count (te->getElementNames (), argLabel) == 1 ;
654-
655- return false ;
648+ SmallVector<Identifier, 4 > scratch;
649+ return llvm::count (ArgList->getArgumentLabels (scratch), argLabel) == 1 ;
656650 };
657651
658652 if (useArgLabel ()) {
@@ -668,11 +662,7 @@ class FunctionArgApplyInfo {
668662
669663 // / Whether the argument is a trailing closure.
670664 bool isTrailingClosure () const {
671- if (auto trailingClosureArg =
672- ArgListExpr->getUnlabeledTrailingClosureIndexOfPackedArgument ())
673- return ArgIdx >= *trailingClosureArg;
674-
675- return false ;
665+ return ArgList->isRawTrailingClosureIndex (ArgIdx);
676666 }
677667
678668 // / \returns The interface type for the function being applied. Note that this
@@ -2794,25 +2784,19 @@ class ConstraintSystem {
27942784 // / we're exploring.
27952785 SolverState *solverState = nullptr ;
27962786
2797- struct ArgumentInfo {
2798- ArrayRef<Identifier> Labels;
2799- Optional<unsigned > UnlabeledTrailingClosureIndex;
2800- };
2801-
28022787 // / A mapping from the constraint locators for references to various
28032788 // / names (e.g., member references, normal name references, possible
2804- // / constructions) to the argument labels provided in the call to
2805- // / that locator.
2806- llvm::DenseMap<ConstraintLocator *, ArgumentInfo> ArgumentInfos;
2789+ // / constructions) to the argument lists for the call to that locator.
2790+ llvm::DenseMap<ConstraintLocator *, ArgumentList *> ArgumentLists;
28072791
28082792 // / Form a locator that can be used to retrieve argument information cached in
28092793 // / the constraint system for the callee described by the anchor of the
28102794 // / passed locator.
28112795 ConstraintLocator *getArgumentInfoLocator (ConstraintLocator *locator);
28122796
2813- // / Retrieve the argument info that is associated with a member
2797+ // / Retrieve the argument list that is associated with a member
28142798 // / reference at the given locator.
2815- Optional<ArgumentInfo> getArgumentInfo (ConstraintLocator *locator);
2799+ ArgumentList * getArgumentList (ConstraintLocator *locator);
28162800
28172801 Optional<SelectedOverload>
28182802 findSelectedOverloadFor (ConstraintLocator *locator) const {
@@ -5197,10 +5181,10 @@ class ConstraintSystem {
51975181
51985182 // / Check whether given AST node represents an argument of an application
51995183 // / of some sort (call, operator invocation, subscript etc.)
5200- // / and return AST node representing and argument index . E.g. for regular
5201- // / calls `test(42)` passing `42` should return node representing
5202- // / entire call and index `0`.
5203- Optional<std::pair<Expr *, unsigned >> isArgumentExpr (Expr *expr);
5184+ // / and returns a locator for the argument application . E.g. for regular
5185+ // / calls `test(42)` passing `42` should return a locator with the entire call
5186+ // / as the anchor, and a path to the argument at index `0`.
5187+ ConstraintLocator * getArgumentLocator (Expr *expr);
52045188
52055189 SWIFT_DEBUG_DUMP;
52065190 SWIFT_DEBUG_DUMPER (dump(Expr *));
0 commit comments