mirror of
https://github.com/github/codeql.git
synced 2026-02-07 18:51:06 +01:00
Java: Improve unification check for wildcards with lower bounds.
This commit is contained in:
@@ -48,6 +48,12 @@ module MkUnification<unificationTarget/1 targetLeft, unificationTarget/1 targetR
|
||||
arg2 = t2.getTypeArgument(pos)
|
||||
}
|
||||
|
||||
private RefType getUpperBound(RefType t) {
|
||||
if t instanceof BoundedType
|
||||
then result = t.(BoundedType).getAnUltimateUpperBoundType()
|
||||
else result = t
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `t1` and `t2` are not unifiable.
|
||||
*
|
||||
@@ -84,6 +90,28 @@ module MkUnification<unificationTarget/1 targetLeft, unificationTarget/1 targetR
|
||||
notHaveIntersection(upperbound1, upperbound2)
|
||||
)
|
||||
or
|
||||
exists(RefType lowerbound, RefType upperbound |
|
||||
t1.(Wildcard).getLowerBoundType().(RefType).getSourceDeclaration() = lowerbound and
|
||||
getUpperBound(t2).getSourceDeclaration() = upperbound and
|
||||
not lowerbound instanceof BoundedType
|
||||
or
|
||||
t2.(Wildcard).getLowerBoundType().(RefType).getSourceDeclaration() = lowerbound and
|
||||
getUpperBound(t1).getSourceDeclaration() = upperbound and
|
||||
not lowerbound instanceof BoundedType
|
||||
|
|
||||
not lowerbound.getASourceSupertype*() = upperbound
|
||||
)
|
||||
or
|
||||
exists(BoundedType lowerbound, RefType upperbound |
|
||||
t1.(Wildcard).getLowerBoundType() = lowerbound and
|
||||
getUpperBound(t2) = upperbound
|
||||
or
|
||||
t2.(Wildcard).getLowerBoundType() = lowerbound and
|
||||
getUpperBound(t1) = upperbound
|
||||
|
|
||||
notHaveIntersection(lowerbound.getUpperBoundType(), upperbound)
|
||||
)
|
||||
or
|
||||
not (
|
||||
t1 instanceof Array and t2 instanceof Array
|
||||
or
|
||||
|
||||
Reference in New Issue
Block a user