@@ -179,6 +179,8 @@ class ArgumentPosition extends TArgumentPosition {
179
179
string toString ( ) {
180
180
this .isSelf ( ) and result = "self"
181
181
or
182
+ this .isLambdaSelf ( ) and result = "lambda self"
183
+ or
182
184
exists ( int pos | this .isPositional ( pos ) and result = "position " + pos )
183
185
or
184
186
exists ( string name | this .isKeyword ( name ) and result = "keyword " + name )
@@ -1647,23 +1649,34 @@ private class SynthCapturePostUpdateNode extends PostUpdateNodeImpl, SynthCaptur
1647
1649
* separate node and parameter/argument positions in order to distinguish
1648
1650
* "lambda self" from "normal self", as lambdas may also access outer `self`
1649
1651
* variables (through variable capture).
1652
+ *
1653
+ * TODO:
1654
+ * We might want a synthetic node here, but currently that incurs problems
1655
+ * with non-monotonic recursion, because of the use of `resolveCall` in the
1656
+ * char pred. This may be solvable by using
1657
+ * `CallGraphConstruction::Make` in staed of
1658
+ * `CallGraphConstruction::Simple::Make` appropriately.
1650
1659
*/
1651
- class SynthCaptureArgumentNode extends TSynthCapturingClosureArgumentNode , ArgumentNode {
1660
+ class CapturingClosureArgumentNode extends CfgNode , ArgumentNode {
1652
1661
CallNode callNode ;
1653
1662
1654
- SynthCaptureArgumentNode ( ) {
1655
- this = TSynthCapturingClosureArgumentNode ( callNode ) and
1656
- // We would prefer to put this restriction in the charpred for the branch,
1657
- // but that incurs non-monotonic recursion.
1663
+ CapturingClosureArgumentNode ( ) {
1664
+ this .getNode ( ) = callNode .getFunction ( ) and
1658
1665
exists ( Function target | resolveCall ( callNode , target , _) |
1659
1666
target = any ( VariableCapture:: CapturedVariable v ) .getACapturingScope ( )
1660
1667
)
1661
1668
}
1662
1669
1670
+ override string toString ( ) { result = "Capturing closure argument" }
1671
+
1672
+ // final override Location getLocation() { result = callNode.getLocation() }
1663
1673
override predicate argumentOf ( DataFlowCall call , ArgumentPosition pos ) {
1664
1674
callNode = call .getNode ( ) and
1665
1675
pos .isLambdaSelf ( )
1666
1676
}
1677
+
1678
+ /** Gets the `CallNode` that is being passed as an argument to itself. */
1679
+ CallNode getCallNode ( ) { result = callNode }
1667
1680
}
1668
1681
1669
1682
/** Gets a viable run-time target for the call `call`. */
0 commit comments