Merge pull request #12954 from aschackmull/java/implicitlypublic

Java: Add SrcCallable.isImplicitlyPublic convenience predicate.
This commit is contained in:
Anders Schack-Mulligen
2023-04-28 10:07:45 +02:00
committed by GitHub

View File

@@ -379,6 +379,19 @@ class SrcCallable extends Callable {
this.isProtected() and not tsub.isFinal()
)
}
/**
* Holds if this callable is implicitly public in the sense that it can be the
* target of virtual dispatch by a call from outside the codebase.
*/
predicate isImplicitlyPublic() {
this.isEffectivelyPublic()
or
exists(SrcMethod m |
m.(SrcCallable).isEffectivelyPublic() and
m.getAPossibleImplementationOfSrcMethod() = this
)
}
}
/** Gets the erasure of `t1` if it is a raw type, or `t1` itself otherwise. */