mirror of
https://github.com/github/codeql.git
synced 2026-05-01 11:45:14 +02:00
handle this parameters when finding unreachable overloads
This commit is contained in:
@@ -100,6 +100,13 @@ predicate signaturesMatch(MethodSignature method, MethodSignature other) {
|
||||
method.getName() = other.getName() and
|
||||
// same number of parameters.
|
||||
method.getBody().getNumParameter() = other.getBody().getNumParameter() and
|
||||
// same this parameter (if exists)
|
||||
(
|
||||
not exists(method.getBody().getThisTypeAnnotation()) and
|
||||
not exists(other.getBody().getThisTypeAnnotation())
|
||||
or
|
||||
method.getBody().getThisTypeAnnotation() = other.getBody().getThisTypeAnnotation()
|
||||
) and
|
||||
// The types are compared in matchingCallSignature. This is sanity-check that the textual representation of the type-annotations are somewhat similar.
|
||||
forall(int i | i in [0 .. -1 + method.getBody().getNumParameter()] |
|
||||
getParameterTypeAnnotation(method, i) = getParameterTypeAnnotation(other, i)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
| 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 |
|
||||
| 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 |
|
||||
| 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 |
|
||||
| tst.ts:21:3:21:30 | method( ... number; | This overload of method() is unreachable, the $@ overload will always be selected. | tst.ts:20:3:20:30 | method( ... string; | previous |
|
||||
| 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 |
|
||||
|
||||
@@ -14,6 +14,9 @@ declare class Foobar {
|
||||
on(event: string, fn?: (event?: any, ...args: any[]) => void): Function;
|
||||
on(event: string, fn?: (event?: any, ...args: any[]) => void): Function; // NOT OK.
|
||||
|
||||
foo(this: string): string;
|
||||
foo(this: number): number; // OK
|
||||
|
||||
}
|
||||
|
||||
declare class Base {
|
||||
|
||||
Reference in New Issue
Block a user