Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fe8dfee

Browse files
committed
Java: Add some this-qualifiers.
1 parent 411891c commit fe8dfee

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

java/ql/src/semmle/code/java/Type.qll

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ class RefType extends Type, Annotatable, Modifiable, @reftype {
420420
* Holds if this type declares or inherits method `m`, which is declared
421421
* in `declaringType`.
422422
*/
423-
predicate hasMethod(Method m, RefType declaringType) { hasMethod(m, declaringType, false) }
423+
predicate hasMethod(Method m, RefType declaringType) { this.hasMethod(m, declaringType, false) }
424424

425425
/**
426426
* Holds if this type declares or inherits method `m`, which is declared
@@ -430,13 +430,13 @@ class RefType extends Type, Annotatable, Modifiable, @reftype {
430430
*/
431431
cached
432432
predicate hasMethod(Method m, RefType declaringType, boolean hidden) {
433-
hasNonInterfaceMethod(m, declaringType, hidden)
433+
this.hasNonInterfaceMethod(m, declaringType, hidden)
434434
or
435-
hasInterfaceMethod(m, declaringType) and hidden = false
435+
this.hasInterfaceMethod(m, declaringType) and hidden = false
436436
}
437437

438438
private predicate hasNonInterfaceMethod(Method m, RefType declaringType, boolean hidden) {
439-
m = getAMethod() and
439+
m = this.getAMethod() and
440440
this = declaringType and
441441
not declaringType instanceof Interface and
442442
hidden = false
@@ -461,20 +461,20 @@ class RefType extends Type, Annotatable, Modifiable, @reftype {
461461
private predicate cannotInheritInterfaceMethod(string signature) {
462462
methods(_, _, signature, _, this, _)
463463
or
464-
exists(Method m | hasNonInterfaceMethod(m, _, false) and methods(m, _, signature, _, _, _))
464+
exists(Method m | this.hasNonInterfaceMethod(m, _, false) and methods(m, _, signature, _, _, _))
465465
}
466466

467467
private predicate interfaceMethodCandidateWithSignature(
468468
Method m, string signature, RefType declaringType
469469
) {
470-
m = getAMethod() and
470+
m = this.getAMethod() and
471471
this = declaringType and
472472
declaringType instanceof Interface and
473473
methods(m, _, signature, _, _, _)
474474
or
475475
exists(RefType sup |
476476
sup.interfaceMethodCandidateWithSignature(m, signature, declaringType) and
477-
not cannotInheritInterfaceMethod(signature) and
477+
not this.cannotInheritInterfaceMethod(signature) and
478478
this.extendsOrImplements(sup) and
479479
m.isInheritable()
480480
)
@@ -483,8 +483,8 @@ class RefType extends Type, Annotatable, Modifiable, @reftype {
483483
pragma[nomagic]
484484
private predicate overrideEquivalentInterfaceMethodCandidates(Method m1, Method m2) {
485485
exists(string signature |
486-
interfaceMethodCandidateWithSignature(m1, signature, _) and
487-
interfaceMethodCandidateWithSignature(m2, signature, _) and
486+
this.interfaceMethodCandidateWithSignature(m1, signature, _) and
487+
this.interfaceMethodCandidateWithSignature(m2, signature, _) and
488488
m1 != m2 and
489489
m2.overrides(_) and
490490
any(Method m).overrides(m1)
@@ -494,27 +494,27 @@ class RefType extends Type, Annotatable, Modifiable, @reftype {
494494
pragma[noinline]
495495
private predicate overriddenInterfaceMethodCandidate(Method m) {
496496
exists(Method m2 |
497-
overrideEquivalentInterfaceMethodCandidates(m, m2) and
497+
this.overrideEquivalentInterfaceMethodCandidates(m, m2) and
498498
m2.overrides(m)
499499
)
500500
}
501501

502502
private predicate hasInterfaceMethod(Method m, RefType declaringType) {
503-
interfaceMethodCandidateWithSignature(m, _, declaringType) and
504-
not overriddenInterfaceMethodCandidate(m)
503+
this.interfaceMethodCandidateWithSignature(m, _, declaringType) and
504+
not this.overriddenInterfaceMethodCandidate(m)
505505
}
506506

507507
/** Holds if this type declares or inherits the specified member. */
508508
predicate inherits(Member m) {
509509
exists(Field f | f = m |
510-
f = getAField()
510+
f = this.getAField()
511511
or
512-
not f.isPrivate() and not declaresField(f.getName()) and getASupertype().inherits(f)
512+
not f.isPrivate() and not this.declaresField(f.getName()) and this.getASupertype().inherits(f)
513513
or
514-
getSourceDeclaration().inherits(f)
514+
this.getSourceDeclaration().inherits(f)
515515
)
516516
or
517-
hasMethod(m.(Method), _)
517+
this.hasMethod(m.(Method), _)
518518
}
519519

520520
/** Holds if this is a top-level type, which is not nested inside any other types. */

0 commit comments

Comments
 (0)