Skip to content

Commit 7c2f26e

Browse files
authored
Merge pull request github#13534 from hvitved/ql/fix-bad-join
QL: Fix bad join
2 parents 277dbdf + 6942925 commit 7c2f26e

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

ql/ql/src/codeql_ql/ast/internal/Predicate.qll

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,28 @@ private module Cached {
9090
)
9191
}
9292

93+
pragma[nomagic]
94+
private ClassPredicate getClassPredicate(Class c, string name, int arity) {
95+
result = c.getClassPredicate(name) and
96+
arity = result.getArity()
97+
}
98+
99+
pragma[nomagic]
100+
private predicate resolveSelfClassCalls0(Class c, string name, int arity, MemberCall mc) {
101+
mc.getBase() instanceof ThisAccess and
102+
c = mc.getEnclosingPredicate().getParent() and
103+
name = mc.getMemberName() and
104+
arity = mc.getNumberOfArguments()
105+
}
106+
93107
/**
94108
* Holds if `mc` is a `this.method()` call to a predicate defined in the same class.
95109
* helps avoid spuriously resolving to predicates in super-classes.
96110
*/
97111
private predicate resolveSelfClassCalls(MemberCall mc, PredicateOrBuiltin p) {
98-
exists(Class c |
99-
mc.getBase() instanceof ThisAccess and
100-
c = mc.getEnclosingPredicate().getParent() and
101-
p = c.getClassPredicate(mc.getMemberName()) and
102-
p.getArity() = mc.getNumberOfArguments()
112+
exists(Class c, string name, int arity |
113+
resolveSelfClassCalls0(c, name, arity, mc) and
114+
p = getClassPredicate(c, name, arity)
103115
)
104116
}
105117

0 commit comments

Comments
 (0)