Attempt to fix bad join candidates

This commit is contained in:
Harry Maclean
2022-08-17 17:26:40 +12:00
parent 5cdaae7378
commit 92715bac3a

View File

@@ -173,14 +173,13 @@ class Method extends MethodBase, TMethod {
result = this.getExplicitVisibilityModifier()
or
not exists(this.getExplicitVisibilityModifier()) and
result.getEnclosingModule() = this.getEnclosingModule() and
exists(Namespace n, int methodPos | n.getStmt(methodPos) = this |
exists(Namespace n, int methodPos | isDeclaredIn(this, n, methodPos) |
// The relevant visibility modifier is the closest call that occurs before
// the definition of `m` (typically this means higher up the file).
result =
max(int modifierPos, VisibilityModifier modifier |
modifier.modifiesAmbientVisibility() and
n.getStmt(modifierPos) = modifier and
isDeclaredIn(modifier, n, modifierPos) and
modifierPos < methodPos
|
modifier order by modifierPos
@@ -205,11 +204,20 @@ class Method extends MethodBase, TMethod {
VisibilityModifier getExplicitVisibilityModifier() {
result.getMethodArgument() = this
or
result.getEnclosingModule() = this.getEnclosingModule() and
isDeclaredIn(result, this.getEnclosingModule(), _) and
result.getMethodArgument().getConstantValue().getStringlikeValue() = this.getName()
}
}
/**
* Holds if statement `m` is declared in namespace `n` at position `pos`.
*/
pragma[noinline]
private predicate isDeclaredIn(Stmt m, Namespace n, int pos) {
n = m.getEnclosingModule() and
n.getStmt(pos) = m
}
/** A singleton method. */
class SingletonMethod extends MethodBase, TSingletonMethod {
private Ruby::SingletonMethod g;