Java: Allow dispatch to methods on abstract classes without subtypes.

This commit is contained in:
Anders Schack-Mulligen
2022-08-29 13:48:55 +02:00
parent 6e7dcfcc6e
commit e89b42fc11

View File

@@ -211,10 +211,14 @@ private module Dispatch {
exists(Method m | t.hasMethod(m, _, _) and impl = m.getSourceDeclaration())
}
private predicate isAbstractWithSubclass(SrcRefType t) {
t.isAbstract() and exists(Class c | c.getASourceSupertype() = t)
}
private predicate hasViableSubtype(RefType t, SrcRefType sub) {
sub.extendsOrImplements*(t) and
not sub instanceof Interface and
not sub.isAbstract()
not isAbstractWithSubclass(sub)
}
}