Merge pull request #3573 from aschackmull/java/private-interface-methods

Java: Fix for private interface methods.
This commit is contained in:
yo-h
2020-05-28 20:31:55 -04:00
committed by GitHub

View File

@@ -361,18 +361,23 @@ class Method extends Callable, @method {
override MethodAccess getAReference() { result = Callable.super.getAReference() } override MethodAccess getAReference() { result = Callable.super.getAReference() }
override predicate isPublic() { override predicate isPublic() {
Callable.super.isPublic() or Callable.super.isPublic()
// JLS 9.4: Every method declaration in the body of an interface is implicitly public. or
getDeclaringType() instanceof Interface 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) exists(FunctionalExpr func | func.asMethod() = this)
} }
override predicate isAbstract() { override predicate isAbstract() {
Callable.super.isAbstract() Callable.super.isAbstract()
or 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. // is implicitly abstract.
this.getDeclaringType() instanceof Interface and this.getDeclaringType() instanceof Interface and
not this.isPrivate() and
not this.isDefault() and not this.isDefault() and
not this.isStatic() not this.isStatic()
} }