@@ -1893,6 +1893,9 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
18931893 signature module TypeFlowInput {
18941894 predicate enableTypeFlow ( ) ;
18951895
1896+ /** Holds if `p` is a parameter of a callable with a source node that has a call context. */
1897+ predicate isParameterNodeInSourceCallContext ( ParamNode p ) ;
1898+
18961899 /** Holds if the edge is possibly needed in the direction `call` to `c`. */
18971900 predicate relevantCallEdgeIn ( Call call , Callable c ) ;
18981901
@@ -1953,6 +1956,9 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
19531956 /**
19541957 * Holds if a sequence of calls may propagate the value of `arg` to some
19551958 * argument-to-parameter call edge that strengthens the static type.
1959+ *
1960+ * This predicate is a reverse flow computation, starting at calls that
1961+ * strengthen the type and then following relevant call edges backwards.
19561962 */
19571963 pragma [ nomagic]
19581964 private predicate trackedArgTypeCand ( ArgNode arg ) {
@@ -1987,6 +1993,9 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
19871993 * Holds if `p` is part of a value-propagating call path where the
19881994 * end-points have stronger types than the intermediate parameter and
19891995 * argument nodes.
1996+ *
1997+ * This predicate is a forward flow computation, intersecting with the
1998+ * reverse flow computation done in `trackedArgTypeCand`.
19901999 */
19912000 private predicate trackedParamType ( ParamNode p ) {
19922001 exists ( Call call1 , Callable c1 , ArgNode argOut , Call call2 , Callable c2 , ArgNode argIn |
@@ -2013,6 +2022,8 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
20132022 typeStrongerThanFilter ( at , pt )
20142023 )
20152024 or
2025+ Input:: isParameterNodeInSourceCallContext ( p )
2026+ or
20162027 exists ( ArgNode arg |
20172028 trackedArgType ( arg ) and
20182029 relevantCallEdge ( _, _, arg , p ) and
@@ -2104,8 +2115,12 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
21042115 * context.
21052116 */
21062117 private predicate typeFlowParamType ( ParamNode p , Type t , boolean cc ) {
2107- exists ( Callable c |
2108- Input:: dataFlowNonCallEntry ( c , cc ) and
2118+ exists ( Callable c | Input:: dataFlowNonCallEntry ( c , cc ) |
2119+ cc = true and
2120+ nodeEnclosingCallable ( p , c ) and
2121+ t = getSourceContextParameterNodeType ( p )
2122+ or
2123+ ( cc = false or not exists ( getSourceContextParameterNodeType ( p ) ) ) and
21092124 trackedParamWithType ( p , t , c )
21102125 )
21112126 or
0 commit comments