@@ -1444,6 +1444,21 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
14441444 )
14451445 }
14461446
1447+ pragma [ nomagic]
1448+ private predicate compatibleContainer0 ( ApHeadContent apc , DataFlowType containerType ) {
1449+ exists ( DataFlowType containerType0 , Content c |
1450+ PrevStage:: storeStepCand ( _, _, c , _, _, containerType0 ) and
1451+ compatibleTypesCached ( containerType0 , containerType ) and
1452+ apc = projectToHeadContent ( c )
1453+ )
1454+ }
1455+
1456+ bindingset [ apc, containerType]
1457+ pragma [ inline_late]
1458+ private predicate compatibleContainer ( ApHeadContent apc , DataFlowType containerType ) {
1459+ compatibleContainer0 ( apc , containerType )
1460+ }
1461+
14471462 /**
14481463 * Holds if `node` is reachable with access path `ap` from a source.
14491464 *
@@ -1465,7 +1480,13 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
14651480 ) {
14661481 fwdFlow0 ( node , state , cc , summaryCtx , argT , argAp , t0 , ap , apa ) and
14671482 PrevStage:: revFlow ( node , state , apa ) and
1468- filter ( node , state , t0 , ap , t )
1483+ filter ( node , state , t0 , ap , t ) and
1484+ (
1485+ if castingNodeEx ( node )
1486+ then
1487+ ap instanceof ApNil or compatibleContainer ( getHeadContent ( ap ) , node .getDataFlowType ( ) )
1488+ else any ( )
1489+ )
14691490 }
14701491
14711492 pragma [ nomagic]
@@ -2860,15 +2881,15 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
28602881 private module Stage3Param implements MkStage< Stage2 > :: StageParam {
28612882 private module PrevStage = Stage2;
28622883
2863- class Typ = DataFlowType ;
2884+ class Typ = Unit ;
28642885
28652886 class Ap = ApproxAccessPathFront ;
28662887
28672888 class ApNil = ApproxAccessPathFrontNil ;
28682889
28692890 PrevStage:: Ap getApprox ( Ap ap ) { result = ap .toBoolNonEmpty ( ) }
28702891
2871- Typ getTyp ( DataFlowType t ) { result = t }
2892+ Typ getTyp ( DataFlowType t ) { any ( ) }
28722893
28732894 bindingset [ c, t, tail]
28742895 Ap apCons ( Content c , Typ t , Ap tail ) { result .getAHead ( ) = c and exists ( t ) and exists ( tail ) }
@@ -2905,7 +2926,8 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
29052926 NodeEx node1 , FlowState state1 , NodeEx node2 , FlowState state2 , boolean preservesValue ,
29062927 Typ t , LocalCc lcc
29072928 ) {
2908- localFlowBigStep ( node1 , state1 , node2 , state2 , preservesValue , t , _, _) and
2929+ localFlowBigStep ( node1 , state1 , node2 , state2 , preservesValue , _, _, _) and
2930+ exists ( t ) and
29092931 exists ( lcc )
29102932 }
29112933
@@ -2928,7 +2950,6 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
29282950 // the cons candidates including types are used to construct subsequent
29292951 // access path approximations.
29302952 t0 = t and
2931- ( if castingNodeEx ( node ) then compatibleTypesFilter ( node .getDataFlowType ( ) , t0 ) else any ( ) ) and
29322953 (
29332954 notExpectsContent ( node )
29342955 or
@@ -2937,11 +2958,7 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
29372958 }
29382959
29392960 bindingset [ typ, contentType]
2940- predicate typecheckStore ( Typ typ , DataFlowType contentType ) {
2941- // We need to typecheck stores here, since reverse flow through a getter
2942- // might have a different type here compared to inside the getter.
2943- compatibleTypesFilter ( typ , contentType )
2944- }
2961+ predicate typecheckStore ( Typ typ , DataFlowType contentType ) { any ( ) }
29452962 }
29462963
29472964 private module Stage3 = MkStage< Stage2 > :: Stage< Stage3Param > ;
0 commit comments