@@ -60,18 +60,17 @@ class Call extends DotNet::Call, Expr, @call {
6060 */
6161 cached
6262 override Expr getArgumentForParameter ( DotNet:: Parameter p ) {
63+ // Appears in the positional part of the call
64+ result = this .getImplicitArgument ( p )
65+ or
66+ // Appears in the named part of the call
6367 this .getTarget ( ) .getAParameter ( ) = p and
64- (
65- // Appears in the positional part of the call
66- result = this .getImplicitArgument ( p )
67- or
68- // Appears in the named part of the call
69- result = this .getExplicitArgument ( p .getName ( ) )
70- )
68+ result = this .getExplicitArgument ( p .getName ( ) )
7169 }
7270
7371 pragma [ noinline]
7472 private Expr getImplicitArgument ( DotNet:: Parameter p ) {
73+ this .getTarget ( ) .getAParameter ( ) = p and
7574 not exists ( result .getExplicitArgumentName ( ) ) and
7675 (
7776 p .( Parameter ) .isParams ( ) and
@@ -183,24 +182,38 @@ class Call extends DotNet::Call, Expr, @call {
183182 * Gets the argument that corresponds to parameter `p` of a potential
184183 * run-time target of this call.
185184 *
186- * Does not consider
187- * - default arguments,
188- * - named arguments.
185+ * This takes into account both positional and named arguments, but does not
186+ * consider default arguments.
189187 */
188+ cached
190189 Expr getRuntimeArgumentForParameter ( Parameter p ) {
191- exists ( Callable c |
192- c = this .getARuntimeTarget ( ) and
193- p = c .getAParameter ( ) and
194- (
195- p .isParams ( ) and
196- result = this .getRuntimeArgument ( any ( int i | i >= p .getPosition ( ) ) )
197- or
198- not p .isParams ( ) and
199- result = this .getRuntimeArgument ( p .getPosition ( ) )
200- )
190+ // Appears in the positional part of the call
191+ result = this .getImplicitRuntimeArgument ( p )
192+ or
193+ // Appears in the named part of the call
194+ this .getARuntimeTarget ( ) .getAParameter ( ) = p and
195+ result = this .getExplicitRuntimeArgument ( p .getName ( ) )
196+ }
197+
198+ pragma [ noinline]
199+ private Expr getImplicitRuntimeArgument ( Parameter p ) {
200+ this .getARuntimeTarget ( ) .getAParameter ( ) = p and
201+ not exists ( result .getExplicitArgumentName ( ) ) and
202+ (
203+ p .isParams ( ) and
204+ result = this .getRuntimeArgument ( any ( int i | i >= p .getPosition ( ) ) )
205+ or
206+ not p .isParams ( ) and
207+ result = this .getRuntimeArgument ( p .getPosition ( ) )
201208 )
202209 }
203210
211+ pragma [ nomagic]
212+ private Expr getExplicitRuntimeArgument ( string name ) {
213+ result = this .getARuntimeArgument ( ) and
214+ result .getExplicitArgumentName ( ) = name
215+ }
216+
204217 /**
205218 * Gets the argument that corresponds to a parameter named `name` of a potential
206219 * run-time target of this call.
0 commit comments