@@ -118,17 +118,35 @@ class CallableValue extends Value {
118118 result = this .( CallableObjectInternal ) .getParameterByName ( name )
119119 }
120120
121- ControlFlowNode getArgumentForCall ( CallNode call , NameNode param ) {
122- this .getACall ( ) = call and
123- (
124- exists ( int n | call .getArg ( n ) = result and param = this .getParameter ( n ) )
121+ ControlFlowNode getArgumentForCall ( CallNode call , int n ) {
122+ exists ( ObjectInternal called , int offset |
123+ PointsToInternal:: pointsTo ( call .getFunction ( ) , _, called , _) and
124+ called .functionAndOffset ( this , offset )
125+ |
126+ call .getArg ( n - offset ) = result
125127 or
126- exists ( string name | call .getArgByName ( name ) = result and param = this .getParameterByName ( name ) )
128+ exists ( string name | call .getArgByName ( name ) = result and this .( PythonFunctionObjectInternal ) .getScope ( ) .getArg ( n + offset ) .getName ( ) = name )
129+ or
130+ called instanceof BoundMethodObjectInternal and
131+ offset = 1 and n = 0 and result = call .getFunction ( ) .( AttrNode ) .getObject ( )
127132 )
128- or
129- exists ( BoundMethodObjectInternal bm |
130- result = getArgumentForCall ( call , param ) and
131- this = bm .getFunction ( )
133+ }
134+
135+ ControlFlowNode getNamedArgumentForCall ( CallNode call , string name ) {
136+ exists ( CallableObjectInternal called , int offset |
137+ PointsToInternal:: pointsTo ( call .getFunction ( ) , _, called , _) and
138+ called .functionAndOffset ( this , offset )
139+ |
140+ exists ( int n |
141+ call .getArg ( n ) = result and
142+ this .( PythonFunctionObjectInternal ) .getScope ( ) .getArg ( n + offset ) .getName ( ) = name
143+ )
144+ or
145+ call .getArgByName ( name ) = result and
146+ exists ( this .( PythonFunctionObjectInternal ) .getScope ( ) .getArgByName ( name ) )
147+ or
148+ called instanceof BoundMethodObjectInternal and
149+ offset = 1 and name = "self" and result = call .getFunction ( ) .( AttrNode ) .getObject ( )
132150 )
133151 }
134152
0 commit comments