@@ -183,24 +183,39 @@ class Call extends DotNet::Call, Expr, @call {
183
183
* Gets the argument that corresponds to parameter `p` of a potential
184
184
* run-time target of this call.
185
185
*
186
- * Does not consider
187
- * - default arguments,
188
- * - named arguments.
186
+ * This takes into account both positional and named arguments, but does not
187
+ * consider default arguments.
189
188
*/
189
+ cached
190
190
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
- )
191
+ p = this .getARuntimeTarget ( ) .getAParameter ( ) and
192
+ (
193
+ // Appears in the positional part of the call
194
+ result = this .getImplicitRuntimeArgument ( p )
195
+ or
196
+ // Appears in the named part of the call
197
+ result = this .getExplicitRuntimeArgument ( p .getName ( ) )
198
+ )
199
+ }
200
+
201
+ pragma [ noinline]
202
+ private Expr getImplicitRuntimeArgument ( Parameter p ) {
203
+ not exists ( result .getExplicitArgumentName ( ) ) and
204
+ (
205
+ p .isParams ( ) and
206
+ result = this .getRuntimeArgument ( any ( int i | i >= p .getPosition ( ) ) )
207
+ or
208
+ not p .isParams ( ) and
209
+ result = this .getRuntimeArgument ( p .getPosition ( ) )
201
210
)
202
211
}
203
212
213
+ pragma [ nomagic]
214
+ private Expr getExplicitRuntimeArgument ( string name ) {
215
+ result = this .getARuntimeArgument ( ) and
216
+ result .getExplicitArgumentName ( ) = name
217
+ }
218
+
204
219
/**
205
220
* Gets the argument that corresponds to a parameter named `name` of a potential
206
221
* run-time target of this call.
0 commit comments