@@ -62,6 +62,22 @@ private DataFlow::TypeTrackingNode poorMansFunctionTracker(DataFlow::TypeTracker
62
62
exists ( DataFlow:: TypeTracker t2 | result = poorMansFunctionTracker ( t2 , func ) .track ( t2 , t ) )
63
63
}
64
64
65
+ /**
66
+ * Gets a reference to `func`. `func` must be defined inside a class, and the reference
67
+ * will be inside a different method of the same class.
68
+ */
69
+ private DataFlow:: Node getSimpleMethodReferenceWithinClass ( Function func ) {
70
+ // TODO: Should take MRO into account
71
+ exists ( Class cls , Function otherFunc , DataFlow:: Node selfRefOtherFunc |
72
+ cls .getAMethod ( ) = func and
73
+ cls .getAMethod ( ) = otherFunc
74
+ |
75
+ selfRefOtherFunc .getALocalSource ( ) .( DataFlow:: ParameterNode ) .getParameter ( ) =
76
+ otherFunc .getArg ( 0 ) and
77
+ result .( DataFlow:: AttrRead ) .accesses ( selfRefOtherFunc , func .getName ( ) )
78
+ )
79
+ }
80
+
65
81
/**
66
82
* INTERNAL: Do not use.
67
83
*
@@ -95,13 +111,5 @@ private DataFlow::TypeTrackingNode poorMansFunctionTracker(DataFlow::TypeTracker
95
111
DataFlow:: Node poorMansFunctionTracker ( Function func ) {
96
112
poorMansFunctionTracker ( DataFlow:: TypeTracker:: end ( ) , func ) .flowsTo ( result )
97
113
or
98
- // simple method calls within a class
99
- // TODO: Should take MRO into account
100
- exists ( Class cls , Function otherFunc , DataFlow:: Node selfRef |
101
- cls .getAMethod ( ) = func and
102
- cls .getAMethod ( ) = otherFunc
103
- |
104
- selfRef .getALocalSource ( ) .( DataFlow:: ParameterNode ) .getParameter ( ) = otherFunc .getArg ( 0 ) and
105
- result .( DataFlow:: AttrRead ) .accesses ( selfRef , func .getName ( ) )
106
- )
114
+ result = getSimpleMethodReferenceWithinClass ( func )
107
115
}
0 commit comments