Skip to content

Commit e060708

Browse files
committed
QL: correctly resolve super calls in char preds
1 parent 3252c04 commit e060708

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private module Cached {
8181
// super calls
8282
exists(Super sup, ClassType type, Type supertype |
8383
mc.getBase() = sup and
84-
sup.getEnclosingPredicate().(ClassPredicate).getParent().getType() = type and
84+
sup.getEnclosingPredicate().getParent().(Class).getType() = type and
8585
supertype in [type.getASuperType(), type.getAnInstanceofType()] and
8686
p = supertype.getClassPredicate(mc.getMemberName(), mc.getNumberOfArguments())
8787
)

ql/test/callgraph/Baz.qll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Foo extends string {
2+
Foo() { this = "Foo" }
3+
4+
string getImportedPath() { none() }
5+
}
6+
7+
class Bar extends string, Foo {
8+
Bar() { exists(Foo.super.getImportedPath()) }
9+
10+
override string getImportedPath() { none() }
11+
}

ql/test/callgraph/callgraph.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
getTarget
22
| Bar.qll:5:38:5:47 | PredicateCall | Bar.qll:8:3:8:31 | ClasslessPredicate snapshot |
3+
| Baz.qll:8:18:8:44 | MemberCall | Baz.qll:4:3:4:37 | ClassPredicate getImportedPath |
34
| Foo.qll:5:26:5:30 | PredicateCall | Foo.qll:3:1:3:26 | ClasslessPredicate foo |
45
| Foo.qll:10:21:10:25 | PredicateCall | Foo.qll:8:3:8:28 | ClassPredicate bar |
56
| Foo.qll:14:30:14:40 | MemberCall | Foo.qll:10:3:10:27 | ClassPredicate baz |

0 commit comments

Comments
 (0)