Skip to content

Commit f248c6a

Browse files
committed
Java: Improve unification check for bounded types.
1 parent 6b01f02 commit f248c6a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

java/ql/lib/semmle/code/java/dispatch/Unification.qll

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,24 @@ module MkUnification<unificationTarget/1 targetLeft, unificationTarget/1 targetR
6666
or
6767
failsUnification(t1.(Array).getComponentType(), t2.(Array).getComponentType())
6868
or
69+
exists(RefType upperbound, RefType other |
70+
t1.(BoundedType).getAnUltimateUpperBoundType().getSourceDeclaration() = upperbound and
71+
t2.(RefType).getSourceDeclaration() = other and
72+
not t2 instanceof BoundedType
73+
or
74+
t2.(BoundedType).getAnUltimateUpperBoundType().getSourceDeclaration() = upperbound and
75+
t1.(RefType).getSourceDeclaration() = other and
76+
not t1 instanceof BoundedType
77+
|
78+
not other.getASourceSupertype*() = upperbound
79+
)
80+
or
81+
exists(RefType upperbound1, RefType upperbound2 |
82+
t1.(BoundedType).getAnUltimateUpperBoundType() = upperbound1 and
83+
t2.(BoundedType).getAnUltimateUpperBoundType() = upperbound2 and
84+
notHaveIntersection(upperbound1, upperbound2)
85+
)
86+
or
6987
not (
7088
t1 instanceof Array and t2 instanceof Array
7189
or

0 commit comments

Comments
 (0)