@@ -537,9 +537,14 @@ private DataFlow::LocalSourceNode trackModuleAccess(Module m, TypeTracker t) {
537537 )
538538}
539539
540+ /**
541+ * We exclude steps into `self` parameters, and instead rely on the type of the
542+ * enclosing module.
543+ */
540544pragma [ nomagic]
541545private DataFlow:: LocalSourceNode trackModuleAccessRec ( Module m , TypeTracker t , StepSummary summary ) {
542- StepSummary:: step ( trackModuleAccess ( m , t ) , result , summary )
546+ StepSummary:: step ( trackModuleAccess ( m , t ) , result , summary ) and
547+ not result instanceof SelfParameterNode
543548}
544549
545550pragma [ nomagic]
@@ -603,17 +608,22 @@ private predicate isInstance(DataFlow::Node n, Module tp, boolean exact) {
603608 or
604609 exists ( RelevantCall call , DataFlow:: LocalSourceNode sourceNode |
605610 flowsToMethodCallReceiver ( call , sourceNode , "new" ) and
606- exact = true and
607611 n .asExpr ( ) = call
608612 |
609613 // `C.new`
610- sourceNode = trackModuleAccess ( tp )
614+ sourceNode = trackModuleAccess ( tp ) and
615+ exact = true
611616 or
612617 // `self.new` inside a module
613- selfInModule ( sourceNode .( SsaSelfDefinitionNode ) .getVariable ( ) , tp )
618+ selfInModule ( sourceNode .( SsaSelfDefinitionNode ) .getVariable ( ) , tp ) and
619+ exact = true
614620 or
615621 // `self.new` inside a singleton method
616- selfInMethod ( sourceNode .( SsaSelfDefinitionNode ) .getVariable ( ) , any ( SingletonMethod sm ) , tp )
622+ exists ( MethodBase target |
623+ selfInMethod ( sourceNode .( SsaSelfDefinitionNode ) .getVariable ( ) , target , tp ) and
624+ singletonMethod ( target , _, _) and
625+ exact = false
626+ )
617627 )
618628 or
619629 // `self` reference in method or top-level (but not in module or singleton method,
0 commit comments