File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed
lib/semmle/code/java/dataflow
test/library-tests/typeflow Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -202,6 +202,13 @@ private module Input implements TypeFlowInput<Location> {
202202 t1e = t2e and
203203 unbound ( t2 ) and
204204 not unbound ( t1 )
205+ or
206+ t1e = t2e and
207+ exists ( int pos |
208+ partiallyUnbound ( t2 , pos ) and
209+ not partiallyUnbound ( t1 , pos ) and
210+ not unbound ( t1 )
211+ )
205212 )
206213 }
207214
@@ -370,6 +377,11 @@ private module Input implements TypeFlowInput<Location> {
370377 )
371378 }
372379
380+ /** Holds if `t` is a parameterised type with unrestricted type argument at position `pos`. */
381+ private predicate partiallyUnbound ( ParameterizedType t , int pos ) {
382+ unconstrained ( t .getTypeArgument ( pos ) )
383+ }
384+
373385 Type getErasure ( Type t ) { result = t .getErasure ( ) }
374386
375387 Type getAnAncestor ( Type sub ) { result = sub .getAnAncestor ( ) }
Original file line number Diff line number Diff line change @@ -118,4 +118,12 @@ public void m10(Object o) {
118118 default -> { }
119119 }
120120 }
121+
122+ private static <T > T lookupFoo (Map <String , T > m ) {
123+ return m .get ("foo" );
124+ }
125+
126+ public void m11 (Map <String , String > m ) {
127+ lookupFoo (m );
128+ }
121129}
Original file line number Diff line number Diff line change 1818| A.java:112:23:112:24 | cs | String | false |
1919| A.java:116:13:116:14 | o2 | String | false |
2020| A.java:117:49:117:50 | cs | String | false |
21+ | A.java:123:12:123:12 | m | Map<String,String> | false |
2122| UnionTypes.java:45:7:45:7 | x | Inter | false |
2223| UnionTypes.java:48:23:48:23 | x | Inter | false |
You can’t perform that action at this time.
0 commit comments