@@ -1520,19 +1520,21 @@ abstract class ParameterNodeImpl extends Node {
15201520}
15211521
15221522/**
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
15241524 * flow graph.
15251525 *
15261526 * This is used for tracking flow through captured variables, and we use a
15271527 * separate node and parameter/argument positions in order to distinguish
15281528 * "lambda self" from "normal self", as lambdas may also access outer `self`
15291529 * variables (through variable capture).
15301530 */
1531- class LambdaSelfReferenceNode extends ParameterNodeImpl , TLambdaSelfReferenceNode {
1531+ class SynthCapturingClosureParameterNode extends ParameterNodeImpl ,
1532+ TSynthCapturingClosureParameterNode
1533+ {
15321534 private Function callable ;
15331535
1534- LambdaSelfReferenceNode ( ) {
1535- this = TLambdaSelfReferenceNode ( callable ) and
1536+ SynthCapturingClosureParameterNode ( ) {
1537+ this = TSynthCapturingClosureParameterNode ( callable ) and
15361538 // TODO: Remove this restriction when adding proper support for captured variables in the body of the function we generate for comprehensions
15371539 exists ( TFunction ( callable ) )
15381540 }
@@ -1635,11 +1637,22 @@ private class SynthCapturePostUpdateNode extends PostUpdateNodeImpl, SynthCaptur
16351637 override Node getPreUpdateNode ( ) { result = pre }
16361638}
16371639
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 {
16391650 CallNode callNode ;
16401651
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.
16431656 exists ( Function target | resolveCall ( callNode , target , _) |
16441657 target = any ( VariableCapture:: CapturedVariable v ) .getACapturingScope ( )
16451658 )
0 commit comments