mirror of
https://github.com/github/codeql.git
synced 2026-02-28 21:03:50 +01:00
Java: Add some this-qualifiers.
This commit is contained in:
@@ -420,7 +420,7 @@ class RefType extends Type, Annotatable, Modifiable, @reftype {
|
||||
* Holds if this type declares or inherits method `m`, which is declared
|
||||
* in `declaringType`.
|
||||
*/
|
||||
predicate hasMethod(Method m, RefType declaringType) { hasMethod(m, declaringType, false) }
|
||||
predicate hasMethod(Method m, RefType declaringType) { this.hasMethod(m, declaringType, false) }
|
||||
|
||||
/**
|
||||
* Holds if this type declares or inherits method `m`, which is declared
|
||||
@@ -430,13 +430,13 @@ class RefType extends Type, Annotatable, Modifiable, @reftype {
|
||||
*/
|
||||
cached
|
||||
predicate hasMethod(Method m, RefType declaringType, boolean hidden) {
|
||||
hasNonInterfaceMethod(m, declaringType, hidden)
|
||||
this.hasNonInterfaceMethod(m, declaringType, hidden)
|
||||
or
|
||||
hasInterfaceMethod(m, declaringType) and hidden = false
|
||||
this.hasInterfaceMethod(m, declaringType) and hidden = false
|
||||
}
|
||||
|
||||
private predicate hasNonInterfaceMethod(Method m, RefType declaringType, boolean hidden) {
|
||||
m = getAMethod() and
|
||||
m = this.getAMethod() and
|
||||
this = declaringType and
|
||||
not declaringType instanceof Interface and
|
||||
hidden = false
|
||||
@@ -461,20 +461,20 @@ class RefType extends Type, Annotatable, Modifiable, @reftype {
|
||||
private predicate cannotInheritInterfaceMethod(string signature) {
|
||||
methods(_, _, signature, _, this, _)
|
||||
or
|
||||
exists(Method m | hasNonInterfaceMethod(m, _, false) and methods(m, _, signature, _, _, _))
|
||||
exists(Method m | this.hasNonInterfaceMethod(m, _, false) and methods(m, _, signature, _, _, _))
|
||||
}
|
||||
|
||||
private predicate interfaceMethodCandidateWithSignature(
|
||||
Method m, string signature, RefType declaringType
|
||||
) {
|
||||
m = getAMethod() and
|
||||
m = this.getAMethod() and
|
||||
this = declaringType and
|
||||
declaringType instanceof Interface and
|
||||
methods(m, _, signature, _, _, _)
|
||||
or
|
||||
exists(RefType sup |
|
||||
sup.interfaceMethodCandidateWithSignature(m, signature, declaringType) and
|
||||
not cannotInheritInterfaceMethod(signature) and
|
||||
not this.cannotInheritInterfaceMethod(signature) and
|
||||
this.extendsOrImplements(sup) and
|
||||
m.isInheritable()
|
||||
)
|
||||
@@ -483,8 +483,8 @@ class RefType extends Type, Annotatable, Modifiable, @reftype {
|
||||
pragma[nomagic]
|
||||
private predicate overrideEquivalentInterfaceMethodCandidates(Method m1, Method m2) {
|
||||
exists(string signature |
|
||||
interfaceMethodCandidateWithSignature(m1, signature, _) and
|
||||
interfaceMethodCandidateWithSignature(m2, signature, _) and
|
||||
this.interfaceMethodCandidateWithSignature(m1, signature, _) and
|
||||
this.interfaceMethodCandidateWithSignature(m2, signature, _) and
|
||||
m1 != m2 and
|
||||
m2.overrides(_) and
|
||||
any(Method m).overrides(m1)
|
||||
@@ -494,27 +494,27 @@ class RefType extends Type, Annotatable, Modifiable, @reftype {
|
||||
pragma[noinline]
|
||||
private predicate overriddenInterfaceMethodCandidate(Method m) {
|
||||
exists(Method m2 |
|
||||
overrideEquivalentInterfaceMethodCandidates(m, m2) and
|
||||
this.overrideEquivalentInterfaceMethodCandidates(m, m2) and
|
||||
m2.overrides(m)
|
||||
)
|
||||
}
|
||||
|
||||
private predicate hasInterfaceMethod(Method m, RefType declaringType) {
|
||||
interfaceMethodCandidateWithSignature(m, _, declaringType) and
|
||||
not overriddenInterfaceMethodCandidate(m)
|
||||
this.interfaceMethodCandidateWithSignature(m, _, declaringType) and
|
||||
not this.overriddenInterfaceMethodCandidate(m)
|
||||
}
|
||||
|
||||
/** Holds if this type declares or inherits the specified member. */
|
||||
predicate inherits(Member m) {
|
||||
exists(Field f | f = m |
|
||||
f = getAField()
|
||||
f = this.getAField()
|
||||
or
|
||||
not f.isPrivate() and not declaresField(f.getName()) and getASupertype().inherits(f)
|
||||
not f.isPrivate() and not this.declaresField(f.getName()) and this.getASupertype().inherits(f)
|
||||
or
|
||||
getSourceDeclaration().inherits(f)
|
||||
this.getSourceDeclaration().inherits(f)
|
||||
)
|
||||
or
|
||||
hasMethod(m.(Method), _)
|
||||
this.hasMethod(m.(Method), _)
|
||||
}
|
||||
|
||||
/** Holds if this is a top-level type, which is not nested inside any other types. */
|
||||
|
||||
Reference in New Issue
Block a user