@@ -363,7 +363,11 @@ class CallableValue extends Value {
363363 or
364364 exists ( string name |
365365 call .getArgByName ( name ) = result and
366- this .( PythonFunctionObjectInternal ) .getScope ( ) .getArg ( n ) .getName ( ) = name
366+ (
367+ this .( PythonFunctionObjectInternal ) .getScope ( ) .getArg ( n ) .getName ( ) = name
368+ or
369+ this .( BoundMethodObjectInternal ) .getFunction ( ) .getScope ( ) .getArg ( n + 1 ) .getName ( ) = name
370+ )
367371 )
368372 or
369373 called instanceof BoundMethodObjectInternal and
@@ -382,11 +386,19 @@ class CallableValue extends Value {
382386 |
383387 exists ( int n |
384388 call .getArg ( n ) = result and
385- this .( PythonFunctionObjectInternal ) .getScope ( ) .getArg ( n + offset ) .getName ( ) = name
389+ exists ( PythonFunctionObjectInternal py |
390+ py = this or py = this .( BoundMethodObjectInternal ) .getFunction ( )
391+ |
392+ py .getScope ( ) .getArg ( n + offset ) .getName ( ) = name
393+ )
386394 )
387395 or
388396 call .getArgByName ( name ) = result and
389- exists ( this .( PythonFunctionObjectInternal ) .getScope ( ) .getArgByName ( name ) )
397+ exists ( PythonFunctionObjectInternal py |
398+ py = this or py = this .( BoundMethodObjectInternal ) .getFunction ( )
399+ |
400+ exists ( py .getScope ( ) .getArgByName ( name ) )
401+ )
390402 or
391403 called instanceof BoundMethodObjectInternal and
392404 offset = 1 and
@@ -396,6 +408,26 @@ class CallableValue extends Value {
396408 }
397409}
398410
411+ /**
412+ * Class representing bound-methods, such as `o.func`, where `o` is an instance
413+ * of a class that has a callable attribute `func`.
414+ */
415+ class BoundMethodValue extends CallableValue {
416+ BoundMethodValue ( ) { this instanceof BoundMethodObjectInternal }
417+
418+ /**
419+ * Gets the callable that will be used when `this` called.
420+ * The actual callable for `func` in `o.func`.
421+ */
422+ CallableValue getFunction ( ) { result = this .( BoundMethodObjectInternal ) .getFunction ( ) }
423+
424+ /**
425+ * Gets the value that will be used for the `self` parameter when `this` is called.
426+ * The value for `o` in `o.func`.
427+ */
428+ Value getSelf ( ) { result = this .( BoundMethodObjectInternal ) .getSelf ( ) }
429+ }
430+
399431/**
400432 * Class representing classes in the Python program, both Python and built-in.
401433 */
0 commit comments