@@ -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
@@ -2106,7 +2117,9 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
21062117 private predicate typeFlowParamType ( ParamNode p , Type t , boolean cc ) {
21072118 exists ( Callable c |
21082119 Input:: dataFlowNonCallEntry ( c , cc ) and
2109- trackedParamWithType ( p , t , c )
2120+ if cc = true and exists ( getSourceContextParameterNodeType ( ) )
2121+ then t = getSourceContextParameterNodeType ( )
2122+ else trackedParamWithType ( p , t , c )
21102123 )
21112124 or
21122125 exists ( Type t1 , Type t2 |
0 commit comments