@@ -517,32 +517,24 @@ private class FactoryDefinition extends ReactElementDefinition {
517517}
518518
519519/**
520- * Flow analysis for `this` expressions inside a function that is called with
521- * `React.Children.map` or a similar library function that binds `this` of a
522- * callback.
523- *
524- * However, since the function could be invoked in another way, we additionally
525- * still infer the ordinary abstract value.
520+ * Partial invocation for calls to `React.Children.map` or a similar library function
521+ * that binds `this` of a callback.
526522 */
527- private class AnalyzedThisInBoundCallback extends AnalyzedNode , DataFlow:: ThisNode {
528- AnalyzedNode thisSource ;
529-
530- AnalyzedThisInBoundCallback ( ) {
531- exists ( DataFlow:: CallNode bindingCall , string binderName |
523+ private class ReactCallbackPartialInvoke extends DataFlow:: PartialInvokeNode:: Range , DataFlow:: CallNode {
524+ ReactCallbackPartialInvoke ( ) {
525+ exists ( string name |
532526 // React.Children.map or React.Children.forEach
533- binderName = "map" or
534- binderName = "forEach"
527+ name = "map" or
528+ name = "forEach"
535529 |
536- bindingCall = react ( ) .getAPropertyRead ( "Children" ) .getAMemberCall ( binderName ) and
537- 3 = bindingCall .getNumArgument ( ) and
538- getBinder ( ) = bindingCall .getCallback ( 1 ) and
539- thisSource = bindingCall .getArgument ( 2 )
530+ this = react ( ) .getAPropertyRead ( "Children" ) .getAMemberCall ( name ) and
531+ 3 = getNumArgument ( )
540532 )
541533 }
542534
543- override AbstractValue getALocalValue ( ) {
544- result = thisSource . getALocalValue ( ) or
545- result = AnalyzedNode . super . getALocalValue ( )
535+ override DataFlow :: Node getBoundReceiver ( DataFlow :: Node callback ) {
536+ callback = getArgument ( 1 ) and
537+ result = getArgument ( 2 )
546538 }
547539}
548540
0 commit comments