Skip to content

Commit 14b84c6

Browse files
committed
Swift: add MethodDecl.isStatic/0
1 parent 668d79a commit 14b84c6

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

swift/ql/lib/codeql/swift/elements/decl/MethodDecl.qll

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class MethodDecl extends AbstractFunctionDecl {
2626
}
2727

2828
/**
29-
* Holds if this function is called `funcName` and its a member of a
30-
* class, struct, extension, enum or protocol call `typeName`.
29+
* Holds if this function is called `funcName` and is a member of a
30+
* class, struct, extension, enum or protocol called `typeName`.
3131
*/
3232
cached
3333
predicate hasQualifiedName(string typeName, string funcName) {
@@ -46,12 +46,17 @@ class MethodDecl extends AbstractFunctionDecl {
4646
}
4747

4848
/**
49-
* Holds if this function is called `funcName` and its a member of a
50-
* class, struct, extension, enum or protocol call `typeName` in a module
49+
* Holds if this function is called `funcName` and is a member of a
50+
* class, struct, extension, enum or protocol called `typeName` in a module
5151
* called `moduleName`.
5252
*/
5353
predicate hasQualifiedName(string moduleName, string typeName, string funcName) {
5454
this.hasQualifiedName(typeName, funcName) and
5555
this.getModule().getFullName() = moduleName
5656
}
57+
58+
/**
59+
* Holds if this function is a `static` or `class` method, as opposed to an instance method.
60+
*/
61+
predicate isStatic() { this.getSelfParam().getType() instanceof MetatypeType }
5762
}

0 commit comments

Comments
 (0)