@@ -583,7 +583,7 @@ struct SelectedOverload {
583
583
// / Provides information about the application of a function argument to a
584
584
// / parameter.
585
585
class FunctionArgApplyInfo {
586
- Expr *ArgListExpr ;
586
+ ArgumentList *ArgList ;
587
587
Expr *ArgExpr;
588
588
unsigned ArgIdx;
589
589
Type ArgType;
@@ -595,15 +595,15 @@ class FunctionArgApplyInfo {
595
595
const ValueDecl *Callee;
596
596
597
597
public:
598
- FunctionArgApplyInfo (Expr *argListExpr , Expr *argExpr, unsigned argIdx,
598
+ FunctionArgApplyInfo (ArgumentList *argList , Expr *argExpr, unsigned argIdx,
599
599
Type argType, unsigned paramIdx, Type fnInterfaceType,
600
600
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) {}
604
604
605
605
// / \returns The list of the arguments used for this application.
606
- Expr * getArgListExpr () const { return ArgListExpr ; }
606
+ ArgumentList * getArgList () const { return ArgList ; }
607
607
608
608
// / \returns The argument being applied.
609
609
Expr *getArgExpr () const { return ArgExpr; }
@@ -625,11 +625,7 @@ class FunctionArgApplyInfo {
625
625
626
626
// / \returns The label for the argument being applied.
627
627
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);
633
629
}
634
630
635
631
Identifier getParamLabel () const {
@@ -649,10 +645,8 @@ class FunctionArgApplyInfo {
649
645
if (argLabel.empty ())
650
646
return false ;
651
647
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 ;
656
650
};
657
651
658
652
if (useArgLabel ()) {
@@ -668,11 +662,7 @@ class FunctionArgApplyInfo {
668
662
669
663
// / Whether the argument is a trailing closure.
670
664
bool isTrailingClosure () const {
671
- if (auto trailingClosureArg =
672
- ArgListExpr->getUnlabeledTrailingClosureIndexOfPackedArgument ())
673
- return ArgIdx >= *trailingClosureArg;
674
-
675
- return false ;
665
+ return ArgList->isRawTrailingClosureIndex (ArgIdx);
676
666
}
677
667
678
668
// / \returns The interface type for the function being applied. Note that this
@@ -2794,25 +2784,19 @@ class ConstraintSystem {
2794
2784
// / we're exploring.
2795
2785
SolverState *solverState = nullptr ;
2796
2786
2797
- struct ArgumentInfo {
2798
- ArrayRef<Identifier> Labels;
2799
- Optional<unsigned > UnlabeledTrailingClosureIndex;
2800
- };
2801
-
2802
2787
// / A mapping from the constraint locators for references to various
2803
2788
// / 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;
2807
2791
2808
2792
// / Form a locator that can be used to retrieve argument information cached in
2809
2793
// / the constraint system for the callee described by the anchor of the
2810
2794
// / passed locator.
2811
2795
ConstraintLocator *getArgumentInfoLocator (ConstraintLocator *locator);
2812
2796
2813
- // / Retrieve the argument info that is associated with a member
2797
+ // / Retrieve the argument list that is associated with a member
2814
2798
// / reference at the given locator.
2815
- Optional<ArgumentInfo> getArgumentInfo (ConstraintLocator *locator);
2799
+ ArgumentList * getArgumentList (ConstraintLocator *locator);
2816
2800
2817
2801
Optional<SelectedOverload>
2818
2802
findSelectedOverloadFor (ConstraintLocator *locator) const {
@@ -5197,10 +5181,10 @@ class ConstraintSystem {
5197
5181
5198
5182
// / Check whether given AST node represents an argument of an application
5199
5183
// / 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);
5204
5188
5205
5189
SWIFT_DEBUG_DUMP;
5206
5190
SWIFT_DEBUG_DUMPER (dump(Expr *));
0 commit comments