Java: Fix for private interface methods.

This commit is contained in:
Anders Schack-Mulligen
2020-05-27 11:05:41 +02:00
parent f952293ba0
commit a858a8cd42

View File

@@ -361,18 +361,23 @@ class Method extends Callable, @method {
override MethodAccess getAReference() { result = Callable.super.getAReference() }
override predicate isPublic() {
Callable.super.isPublic() or
// JLS 9.4: Every method declaration in the body of an interface is implicitly public.
getDeclaringType() instanceof Interface or
Callable.super.isPublic()
or
// JLS 9.4: Every method declaration in the body of an interface without an
// access modifier is implicitly public.
getDeclaringType() instanceof Interface and
not this.isPrivate()
or
exists(FunctionalExpr func | func.asMethod() = this)
}
override predicate isAbstract() {
Callable.super.isAbstract()
or
// JLS 9.4: An interface method lacking a `default` modifier or a `static` modifier
// JLS 9.4: An interface method lacking a `private`, `default`, or `static` modifier
// is implicitly abstract.
this.getDeclaringType() instanceof Interface and
not this.isPrivate() and
not this.isDefault() and
not this.isStatic()
}