@@ -148,7 +148,7 @@ abstract private class LocalFunctionCreationNode extends NodeImpl, TLocalFunctio
148148 LocalFunction getFunction ( ) { result = function }
149149
150150 ExprNode getAnAccess ( boolean inSameCallable ) {
151- result .getExpr ( ) . ( LocalFunctionAccess ) . getTarget ( ) = this .getFunction ( ) and
151+ isLocalFunctionCallReceiver ( _ , result .getExpr ( ) , this .getFunction ( ) ) and
152152 if result .getEnclosingCallable ( ) = this .getEnclosingCallable ( )
153153 then inSameCallable = true
154154 else inSameCallable = false
@@ -399,7 +399,11 @@ module VariableCapture {
399399
400400 predicate hasBody ( Callable body ) { body = c }
401401
402- predicate hasAliasedAccess ( Expr f ) { closureFlowStep + ( this , f ) and not closureFlowStep ( f , _) }
402+ predicate hasAliasedAccess ( Expr f ) {
403+ closureFlowStep + ( this , f ) and not closureFlowStep ( f , _)
404+ or
405+ isLocalFunctionCallReceiver ( _, f .getAstNode ( ) , c )
406+ }
403407 }
404408
405409 class Callable extends Cs:: Callable {
@@ -881,7 +885,7 @@ module LocalFlow {
881885 exists ( SsaImpl:: getAReadAtNode ( def , node2 .( ExprNode ) .getControlFlowNode ( ) ) )
882886 )
883887 or
884- delegateCreationStep ( node1 , node2 )
888+ node2 = node1 . ( LocalFunctionCreationNode ) . getAnAccess ( true )
885889 or
886890 node1 =
887891 unique( FlowSummaryNode n1 |
@@ -2549,9 +2553,10 @@ class DataFlowType extends TDataFlowType {
25492553 * creations associated with the same type.
25502554 */
25512555 ControlFlowElement getADelegateCreation ( ) {
2552- exists ( Callable callable |
2553- lambdaCreationExpr ( result , callable ) and
2554- this = TDelegateDataFlowType ( callable )
2556+ exists ( Callable callable | this = TDelegateDataFlowType ( callable ) |
2557+ lambdaCreationExpr ( result , callable )
2558+ or
2559+ isLocalFunctionCallReceiver ( _, result , callable )
25552560 )
25562561 }
25572562
@@ -2566,12 +2571,7 @@ class DataFlowType extends TDataFlowType {
25662571DataFlowType getNodeType ( Node n ) {
25672572 result = n .( NodeImpl ) .getDataFlowType ( ) and
25682573 not lambdaCreation ( n , _, _) and
2569- not delegateCreationStep ( _, n )
2570- or
2571- exists ( Node arg |
2572- delegateCreationStep ( arg , n ) and
2573- result = getNodeType ( arg )
2574- )
2574+ not isLocalFunctionCallReceiver ( _, n .asExpr ( ) , _)
25752575 or
25762576 [
25772577 n .asExpr ( ) .( ControlFlowElement ) ,
@@ -2896,7 +2896,7 @@ private predicate lambdaCreationExpr(ControlFlowElement creation, Callable c) {
28962896 c =
28972897 [
28982898 creation .( AnonymousFunctionExpr ) ,
2899- creation .( CallableAccess ) .getTarget ( ) .getUnboundDeclaration ( ) ,
2899+ creation .( DelegateCreation ) . getArgument ( ) . ( CallableAccess ) .getTarget ( ) .getUnboundDeclaration ( ) ,
29002900 creation .( AddressOfExpr ) .getOperand ( ) .( CallableAccess ) .getTarget ( ) .getUnboundDeclaration ( ) ,
29012901 creation .( LocalFunctionStmt ) .getLocalFunction ( )
29022902 ]
@@ -2910,6 +2910,13 @@ predicate lambdaCreation(Node creation, LambdaCallKind kind, DataFlowCallable c)
29102910 exists ( kind )
29112911}
29122912
2913+ private predicate isLocalFunctionCallReceiver (
2914+ LocalFunctionCall call , LocalFunctionAccess receiver , LocalFunction f
2915+ ) {
2916+ receiver .getParent ( ) = call and
2917+ f = receiver .getTarget ( ) .getUnboundDeclaration ( )
2918+ }
2919+
29132920private class LambdaConfiguration extends ControlFlowReachabilityConfiguration {
29142921 LambdaConfiguration ( ) { this = "LambdaConfiguration" }
29152922
@@ -2926,7 +2933,7 @@ private class LambdaConfiguration extends ControlFlowReachabilityConfiguration {
29262933 scope = e2 and
29272934 isSuccessor = true
29282935 or
2929- e1 . ( LocalFunctionAccess ) . getParent ( ) = e2 . ( LocalFunctionCall ) and
2936+ isLocalFunctionCallReceiver ( e2 , e1 , _ ) and
29302937 exactScope = false and
29312938 scope = e2 and
29322939 isSuccessor = true
0 commit comments