usesType: support pattern cases

This commit is contained in:
Chris Smowton
2023-10-26 14:47:50 +01:00
parent 0f434e7f08
commit b6622d2f5b
7 changed files with 74 additions and 0 deletions

View File

@@ -79,6 +79,11 @@ predicate depends(RefType t, RefType dep) {
exists(InstanceOfExpr ioe | t = ioe.getEnclosingCallable().getDeclaringType() |
usesType(ioe.getCheckedType(), dep)
)
or
// the type accessed in a pattern-switch case statement in `t`.
exists(PatternCase pc | t = pc.getEnclosingCallable().getDeclaringType() |
usesType(pc.getDecl().getType(), dep)
)
)
}

View File

@@ -102,6 +102,11 @@ predicate numDepends(RefType t, RefType dep, int value) {
|
usesType(ioe.getCheckedType(), dep)
)
or
// the type accessed in a pattern-switch case statement in `t`.
exists(PatternCase pc | elem = pc and t = pc.getEnclosingCallable().getDeclaringType() |
usesType(pc.getDecl().getType(), dep)
)
)
}