First stab at implementing negative type-test logic for pattern-case

This commit is contained in:
Chris Smowton
2023-11-15 19:13:48 +00:00
parent 8fd4f99a39
commit 0bb051e08c
8 changed files with 88 additions and 25 deletions

View File

@@ -194,13 +194,12 @@ private module Dispatch {
*/
private predicate impossibleDispatchTarget(MethodCall source, Method tgt) {
tgt = viableImpl_v1_cand(source) and
exists(InstanceOfExpr ioe, BaseSsaVariable v, Expr q, RefType t |
exists(TypeTestGuard typeTest, BaseSsaVariable v, Expr q, RefType t |
source.getQualifier() = q and
v.getAUse() = q and
guardControls_v1(ioe, q.getBasicBlock(), false) and
ioe.getExpr() = v.getAUse() and
ioe.getCheckedType().getErasure() = t and
tgt.getDeclaringType().getSourceDeclaration().getASourceSupertype*() = t
typeTest.appliesTypeTest(v.getAUse(), t) and
guardControls_v1(typeTest, q.getBasicBlock(), false) and
tgt.getDeclaringType().getSourceDeclaration().getASourceSupertype*() = t.getErasure()
)
}