mirror of
https://github.com/github/codeql.git
synced 2026-04-27 01:35:13 +02:00
JS: Fix FP in ˚MixedStaticInstanceThisAccess
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
import javascript
|
||||
|
||||
/** Holds if `base` declares or inherits method `m` with the given `name`. */
|
||||
predicate hasMethod(ClassDefinition base, string name, MethodDefinition m) {
|
||||
predicate hasMethod(ClassDefinition base, string name, MethodDeclaration m) {
|
||||
m = base.getMethod(name) or
|
||||
hasMethod(base.getSuperClassDefinition(), name, m)
|
||||
}
|
||||
@@ -22,7 +22,7 @@ predicate hasMethod(ClassDefinition base, string name, MethodDefinition m) {
|
||||
* where `fromMethod` and `toMethod` are of kind `fromKind` and `toKind`, respectively.
|
||||
*/
|
||||
predicate isLocalMethodAccess(
|
||||
PropAccess access, MethodDefinition fromMethod, string fromKind, MethodDefinition toMethod,
|
||||
PropAccess access, MethodDefinition fromMethod, string fromKind, MethodDeclaration toMethod,
|
||||
string toKind
|
||||
) {
|
||||
hasMethod(fromMethod.getDeclaringClass(), access.getPropertyName(), toMethod) and
|
||||
@@ -32,7 +32,7 @@ predicate isLocalMethodAccess(
|
||||
toKind = getKind(toMethod)
|
||||
}
|
||||
|
||||
string getKind(MethodDefinition m) {
|
||||
string getKind(MethodDeclaration m) {
|
||||
if m.isStatic() then result = "static" else result = "instance"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
| abstract.ts:6:9:6:17 | this.test | Access to static method $@ from instance method $@ is not possible through `this`. | abstract.ts:3:5:3:20 | static test() {} | test | abstract.ts:5:5:7:5 | method( ... K\\n } | method |
|
||||
| instanceStatic.js:3:9:3:16 | this.baz | Access to instance method $@ from static method $@ is not possible through `this`. | instanceStatic.js:5:5:7:5 | baz(){\\n\\n } | baz | instanceStatic.js:2:5:4:5 | static ... K\\n } | bar |
|
||||
| staticInstance.js:3:9:3:16 | this.baz | Access to static method $@ from instance method $@ is not possible through `this`. | staticInstance.js:5:5:6:5 | static baz(){\\n } | baz | staticInstance.js:2:5:4:5 | bar(){\\n ... K\\n } | bar |
|
||||
| tst.js:66:9:66:14 | this.f | Access to instance method $@ from static method $@ is not possible through `this`. | tst.js:60:5:62:5 | f() {\\n\\n } | f | tst.js:65:5:67:5 | static ... K\\n } | test |
|
||||
|
||||
Reference in New Issue
Block a user