@@ -892,11 +892,6 @@ module NodeJSLib {
892892 * Get a Node that refers to a NodeJS EventEmitter instance.
893893 */
894894 DataFlow:: SourceNode ref ( ) { result = EventEmitter:: trackEventEmitter ( this ) }
895-
896- /**
897- * Gets the node that will used for comparison when determining whether one EventEmitter can send an event to another EventEmitter.
898- */
899- DataFlow:: SourceNode getBaseEmitter ( ) { result = this }
900895 }
901896
902897 /**
@@ -932,12 +927,18 @@ module NodeJSLib {
932927 class CustomEventEmitter extends NodeJSEventEmitter {
933928 EventEmitterSubClass clazz ;
934929 CustomEventEmitter ( ) {
935- this = clazz .getAnInstanceReference ( )
930+ if exists ( clazz .getAClassReference ( ) .getAnInstantiation ( ) ) then
931+ this = clazz .getAClassReference ( ) .getAnInstantiation ( )
932+ else
933+ // In case there are no explicit instantiations of the clazz, then we still want to track data flow between `this` nodes.
934+ // This cannot produce false flow as the `.ref()` method below is always used when creating event-registrations/event-dispatches.
935+ this = clazz
936936 }
937937
938- // we define that events can flow between all instances of the same class, as we thereby support the `this` references in the class itself.
939- override DataFlow:: SourceNode getBaseEmitter ( ) {
940- result = clazz
938+ override DataFlow:: SourceNode ref ( ) {
939+ result = NodeJSEventEmitter .super .ref ( ) and not this = clazz
940+ or
941+ result = clazz .getAReceiverNode ( )
941942 }
942943 }
943944
@@ -959,8 +960,6 @@ module NodeJSLib {
959960 override NodeJSEventEmitter emitter ;
960961
961962 NodeJSEventDispatch ( ) { this = emitter .ref ( ) .getAMethodCall ( "emit" ) }
962-
963- override EventRegistration:: Range getAReceiver ( ) { emitter .getBaseEmitter ( ) = result .getEmitter ( ) .( NodeJSEventEmitter ) .getBaseEmitter ( ) }
964963 }
965964
966965 /**
0 commit comments