mirror of
https://github.com/github/codeql.git
synced 2026-04-26 01:05:15 +02:00
Java: Minor improvement to TypeFlow for super accesses.
This commit is contained in:
@@ -440,6 +440,18 @@ predicate arrayInstanceOfGuarded(ArrayAccess aa, RefType t) {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `t` is the type of the `this` value corresponding to the the
|
||||
* `SuperAccess`. As the `SuperAccess` expression has the type of the supertype,
|
||||
* the type `t` is a stronger type bound.
|
||||
*/
|
||||
private predicate superAccess(SuperAccess sup, RefType t) {
|
||||
sup.isEnclosingInstanceAccess(t)
|
||||
or
|
||||
sup.isOwnInstanceAccess() and
|
||||
t = sup.getEnclosingCallable().getDeclaringType()
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `n` has type `t` and this information is discarded, such that `t`
|
||||
* might be a better type bound for nodes where `n` flows to. This might include
|
||||
@@ -452,7 +464,8 @@ private predicate typeFlowBaseCand(TypeFlowNode n, RefType t) {
|
||||
downcastSuccessor(n.asExpr(), srctype) or
|
||||
instanceOfGuarded(n.asExpr(), srctype) or
|
||||
arrayInstanceOfGuarded(n.asExpr(), srctype) or
|
||||
n.asExpr().(FunctionalExpr).getConstructedType() = srctype
|
||||
n.asExpr().(FunctionalExpr).getConstructedType() = srctype or
|
||||
superAccess(n.asExpr(), srctype)
|
||||
|
|
||||
t = srctype.(BoundedType).getAnUltimateUpperBoundType()
|
||||
or
|
||||
|
||||
Reference in New Issue
Block a user