Skip to content

Commit 68fb8c5

Browse files
committed
check the type of the this-type, instead of the AST-node
1 parent e0fcc4a commit 68fb8c5

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

javascript/ql/src/Declarations/UnreachableMethodOverloads.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ predicate signaturesMatch(MethodSignature method, MethodSignature other) {
105105
not exists(method.getBody().getThisTypeAnnotation()) and
106106
not exists(other.getBody().getThisTypeAnnotation())
107107
or
108-
method.getBody().getThisTypeAnnotation() = other.getBody().getThisTypeAnnotation()
108+
method.getBody().getThisTypeAnnotation().getType() = other.getBody().getThisTypeAnnotation().getType()
109109
) and
110110
// The types are compared in matchingCallSignature. This is sanity-check that the textual representation of the type-annotations are somewhat similar.
111111
forall(int i | i in [0 .. -1 + method.getBody().getNumParameter()] |
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
| tst.ts:3:3:3:30 | method( ... number; | This overload of method() is unreachable, the $@ overload will always be selected. | tst.ts:2:3:2:30 | method( ... string; | previous |
22
| tst.ts:6:3:6:17 | types1(): any[] | This overload of types1() is unreachable, the $@ overload will always be selected. | tst.ts:5:3:5:18 | types1<T>(): T[] | previous |
33
| tst.ts:15:3:15:74 | on(even ... nction; | This overload of on() is unreachable, the $@ overload will always be selected. | tst.ts:14:3:14:74 | on(even ... nction; | previous |
4-
| tst.ts:24:3:24:30 | method( ... number; | This overload of method() is unreachable, the $@ overload will always be selected. | tst.ts:23:3:23:30 | method( ... string; | previous |
4+
| tst.ts:21:3:21:28 | bar(thi ... number; | This overload of bar() is unreachable, the $@ overload will always be selected. | tst.ts:20:3:20:28 | bar(thi ... string; | previous |
5+
| tst.ts:27:3:27:30 | method( ... number; | This overload of method() is unreachable, the $@ overload will always be selected. | tst.ts:26:3:26:30 | method( ... string; | previous |

javascript/ql/test/query-tests/Declarations/UnreachableOverloads/tst.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ declare class Foobar {
1717
foo(this: string): string;
1818
foo(this: number): number; // OK
1919

20+
bar(this: number): string;
21+
bar(this: number): number; // NOT OK
22+
2023
}
2124

2225
declare class Base {

0 commit comments

Comments
 (0)