@@ -1520,19 +1520,21 @@ abstract class ParameterNodeImpl extends Node {
1520
1520
}
1521
1521
1522
1522
/**
1523
- * The value of a lambda itself at function entry, viewed as a node in a data
1523
+ * The value of a closure itself at function entry, viewed as a node in a data
1524
1524
* flow graph.
1525
1525
*
1526
1526
* This is used for tracking flow through captured variables, and we use a
1527
1527
* separate node and parameter/argument positions in order to distinguish
1528
1528
* "lambda self" from "normal self", as lambdas may also access outer `self`
1529
1529
* variables (through variable capture).
1530
1530
*/
1531
- class LambdaSelfReferenceNode extends ParameterNodeImpl , TLambdaSelfReferenceNode {
1531
+ class SynthCapturingClosureParameterNode extends ParameterNodeImpl ,
1532
+ TSynthCapturingClosureParameterNode
1533
+ {
1532
1534
private Function callable ;
1533
1535
1534
- LambdaSelfReferenceNode ( ) {
1535
- this = TLambdaSelfReferenceNode ( callable ) and
1536
+ SynthCapturingClosureParameterNode ( ) {
1537
+ this = TSynthCapturingClosureParameterNode ( callable ) and
1536
1538
// TODO: Remove this restriction when adding proper support for captured variables in the body of the function we generate for comprehensions
1537
1539
exists ( TFunction ( callable ) )
1538
1540
}
@@ -1635,11 +1637,22 @@ private class SynthCapturePostUpdateNode extends PostUpdateNodeImpl, SynthCaptur
1635
1637
override Node getPreUpdateNode ( ) { result = pre }
1636
1638
}
1637
1639
1638
- class CaptureArgumentNode extends CfgNode , ArgumentNode {
1640
+ /**
1641
+ * The value of a closure itself being passed to the funciton, viewed as a node in a data
1642
+ * flow graph.
1643
+ *
1644
+ * This is used for tracking flow through captured variables, and we use a
1645
+ * separate node and parameter/argument positions in order to distinguish
1646
+ * "lambda self" from "normal self", as lambdas may also access outer `self`
1647
+ * variables (through variable capture).
1648
+ */
1649
+ class SynthCaptureArgumentNode extends TSynthCapturingClosureArgumentNode , ArgumentNode {
1639
1650
CallNode callNode ;
1640
1651
1641
- CaptureArgumentNode ( ) {
1642
- this .getNode ( ) = callNode .getFunction ( ) and
1652
+ SynthCaptureArgumentNode ( ) {
1653
+ this = TSynthCapturingClosureArgumentNode ( callNode ) and
1654
+ // We would prefer to put this restriction in the charpred for the branch,
1655
+ // but that incurs non-monotonic recursion.
1643
1656
exists ( Function target | resolveCall ( callNode , target , _) |
1644
1657
target = any ( VariableCapture:: CapturedVariable v ) .getACapturingScope ( )
1645
1658
)
0 commit comments