mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-10 01:43:59 -05:00
Revert the stuffing of instantiated signatures back into the candidates array
This commit is contained in:
@@ -5234,7 +5234,7 @@ module ts {
|
||||
}
|
||||
var index = excludeArgument ? indexOf(excludeArgument, true) : -1;
|
||||
if (index < 0) {
|
||||
return candidates[i] = candidate;
|
||||
return candidate;
|
||||
}
|
||||
excludeArgument[index] = false;
|
||||
}
|
||||
@@ -5246,7 +5246,6 @@ module ts {
|
||||
// arguments, then we can only report an error based on the type arguments.
|
||||
if (originalCandidate.typeParameters) {
|
||||
var instantiatedCandidate = candidate;
|
||||
candidates[i] = instantiatedCandidate;
|
||||
if (typeArgumentsAreValid) {
|
||||
candidateForArgumentError = instantiatedCandidate;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/expressions/functionCalls/overloadResolution.ts(27,5): error TS2345: Argument of type '{}' is not assignable to parameter of type 'number'.
|
||||
tests/cases/conformance/expressions/functionCalls/overloadResolution.ts(41,11): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'.
|
||||
tests/cases/conformance/expressions/functionCalls/overloadResolution.ts(63,1): error TS2346: Supplied parameters do not match any signature of call target.
|
||||
tests/cases/conformance/expressions/functionCalls/overloadResolution.ts(70,5): error TS2344: Type 'string' does not satisfy the constraint 'number'.
|
||||
tests/cases/conformance/expressions/functionCalls/overloadResolution.ts(71,5): error TS2344: Type 'number' does not satisfy the constraint 'string'.
|
||||
tests/cases/conformance/expressions/functionCalls/overloadResolution.ts(70,21): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.
|
||||
tests/cases/conformance/expressions/functionCalls/overloadResolution.ts(71,21): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'.
|
||||
tests/cases/conformance/expressions/functionCalls/overloadResolution.ts(81,5): error TS2344: Type 'boolean' does not satisfy the constraint 'number'.
|
||||
tests/cases/conformance/expressions/functionCalls/overloadResolution.ts(84,5): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number'.
|
||||
tests/cases/conformance/expressions/functionCalls/overloadResolution.ts(85,11): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
|
||||
@@ -87,11 +87,11 @@ tests/cases/conformance/expressions/functionCalls/overloadResolution.ts(91,22):
|
||||
function fn4() { }
|
||||
fn4<string, number>('', 3);
|
||||
fn4<string, number>(3, ''); // Error
|
||||
~~~~~~
|
||||
!!! error TS2344: Type 'string' does not satisfy the constraint 'number'.
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.
|
||||
fn4<number, string>('', 3); // Error
|
||||
~~~~~~
|
||||
!!! error TS2344: Type 'number' does not satisfy the constraint 'string'.
|
||||
~~
|
||||
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'.
|
||||
fn4<number, string>(3, '');
|
||||
|
||||
// Generic overloads with constraints called without type arguments but with types that satisfy the constraints
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors.ts(27,9): error TS2345: Argument of type '{}' is not assignable to parameter of type 'number'.
|
||||
tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors.ts(43,1): error TS2346: Supplied parameters do not match any signature of call target.
|
||||
tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors.ts(43,15): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'.
|
||||
tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors.ts(67,1): error TS2346: Supplied parameters do not match any signature of call target.
|
||||
tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors.ts(77,9): error TS2344: Type 'string' does not satisfy the constraint 'number'.
|
||||
tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors.ts(78,9): error TS2344: Type 'number' does not satisfy the constraint 'string'.
|
||||
tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors.ts(77,25): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.
|
||||
tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors.ts(78,25): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'.
|
||||
tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors.ts(88,9): error TS2344: Type 'boolean' does not satisfy the constraint 'number'.
|
||||
tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors.ts(91,9): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number'.
|
||||
tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors.ts(92,15): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
|
||||
@@ -56,8 +56,8 @@ tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors
|
||||
|
||||
// Generic and non - generic overload where non - generic overload is the only candidate when called with type arguments
|
||||
new fn2<Date>('', 0); // Error
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2346: Supplied parameters do not match any signature of call target.
|
||||
~~
|
||||
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'.
|
||||
|
||||
// Generic and non - generic overload where non - generic overload is the only candidate when called without type arguments
|
||||
new fn2('', 0); // OK
|
||||
@@ -94,11 +94,11 @@ tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors
|
||||
|
||||
new fn4<string, number>('', 3);
|
||||
new fn4<string, number>(3, ''); // Error
|
||||
~~~~~~
|
||||
!!! error TS2344: Type 'string' does not satisfy the constraint 'number'.
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.
|
||||
new fn4<number, string>('', 3); // Error
|
||||
~~~~~~
|
||||
!!! error TS2344: Type 'number' does not satisfy the constraint 'string'.
|
||||
~~
|
||||
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'.
|
||||
new fn4<number, string>(3, '');
|
||||
|
||||
// Generic overloads with constraints called without type arguments but with types that satisfy the constraints
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(14,5): error TS2323: Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(14,37): error TS2345: Argument of type 'D' is not assignable to parameter of type 'A'.
|
||||
tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(16,27): error TS2345: Argument of type '(x: D) => G<D>' is not assignable to parameter of type '(x: B) => any'.
|
||||
tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(16,5): error TS2323: Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(16,38): error TS2344: Type 'D' does not satisfy the constraint 'A'.
|
||||
tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(18,27): error TS2345: Argument of type '(x: D) => G<D>' is not assignable to parameter of type '(x: B) => any'.
|
||||
tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(19,12): error TS2344: Type 'D' does not satisfy the constraint 'A'.
|
||||
@@ -20,22 +20,22 @@ tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(19,12):
|
||||
declare function foo(arg: (x: C) => any): string;
|
||||
declare function foo(arg: (x: B) => any): number;
|
||||
|
||||
var result: number = foo(x => new G(x)); // No error, returns number
|
||||
var result: number = foo(x => new G(x)); // x has type D, new G(x) fails, so first overload is picked.
|
||||
~~~~~~
|
||||
!!! error TS2323: Type 'string' is not assignable to type 'number'.
|
||||
~
|
||||
!!! error TS2345: Argument of type 'D' is not assignable to parameter of type 'A'.
|
||||
|
||||
var result2: number = foo(x => new G<typeof x>(x)); // No error, returns number
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '(x: D) => G<D>' is not assignable to parameter of type '(x: B) => any'.
|
||||
var result2: number = foo(x => new G<typeof x>(x)); // x has type D, new G(x) fails, so first overload is picked.
|
||||
~~~~~~~
|
||||
!!! error TS2323: Type 'string' is not assignable to type 'number'.
|
||||
~~~~~~~~
|
||||
!!! error TS2344: Type 'D' does not satisfy the constraint 'A'.
|
||||
|
||||
var result3: string = foo(x => { // returns string because the C overload is picked
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
var y: G<typeof x>; // error that C does not satisfy constraint
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
var result3: string = foo(x => { // x has type D
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
var y: G<typeof x>; // error that D does not satisfy constraint, y is of type G<D>, entire call to foo is an error
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2344: Type 'D' does not satisfy the constraint 'A'.
|
||||
return y;
|
||||
|
||||
@@ -12,12 +12,12 @@ declare function foo(arg: (x: D) => number): string;
|
||||
declare function foo(arg: (x: C) => any): string;
|
||||
declare function foo(arg: (x: B) => any): number;
|
||||
|
||||
var result: number = foo(x => new G(x)); // No error, returns number
|
||||
var result: number = foo(x => new G(x)); // x has type D, new G(x) fails, so first overload is picked.
|
||||
|
||||
var result2: number = foo(x => new G<typeof x>(x)); // No error, returns number
|
||||
var result2: number = foo(x => new G<typeof x>(x)); // x has type D, new G(x) fails, so first overload is picked.
|
||||
|
||||
var result3: string = foo(x => { // returns string because the C overload is picked
|
||||
var y: G<typeof x>; // error that C does not satisfy constraint
|
||||
var result3: string = foo(x => { // x has type D
|
||||
var y: G<typeof x>; // error that D does not satisfy constraint, y is of type G<D>, entire call to foo is an error
|
||||
return y;
|
||||
});
|
||||
|
||||
@@ -28,9 +28,9 @@ var G = (function () {
|
||||
}
|
||||
return G;
|
||||
})();
|
||||
var result = foo(function (x) { return new G(x); }); // No error, returns number
|
||||
var result2 = foo(function (x) { return new G(x); }); // No error, returns number
|
||||
var result = foo(function (x) { return new G(x); }); // x has type D, new G(x) fails, so first overload is picked.
|
||||
var result2 = foo(function (x) { return new G(x); }); // x has type D, new G(x) fails, so first overload is picked.
|
||||
var result3 = foo(function (x) {
|
||||
var y; // error that C does not satisfy constraint
|
||||
var y; // error that D does not satisfy constraint, y is of type G<D>, entire call to foo is an error
|
||||
return y;
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
tests/cases/compiler/typeArgumentConstraintResolution1.ts(4,6): error TS2344: Type 'Date' does not satisfy the constraint 'Number'.
|
||||
tests/cases/compiler/typeArgumentConstraintResolution1.ts(11,6): error TS2344: Type 'Date' does not satisfy the constraint 'Number'.
|
||||
tests/cases/compiler/typeArgumentConstraintResolution1.ts(4,12): error TS2345: Argument of type 'string' is not assignable to parameter of type 'Date'.
|
||||
tests/cases/compiler/typeArgumentConstraintResolution1.ts(11,12): error TS2345: Argument of type 'string' is not assignable to parameter of type 'Date'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/typeArgumentConstraintResolution1.ts (2 errors) ====
|
||||
@@ -7,8 +7,8 @@ tests/cases/compiler/typeArgumentConstraintResolution1.ts(11,6): error TS2344: T
|
||||
function foo1<T extends Number>(test: string);
|
||||
function foo1<T extends String>(test: any) { }
|
||||
foo1<Date>(""); // should error
|
||||
~~~~
|
||||
!!! error TS2344: Type 'Date' does not satisfy the constraint 'Number'.
|
||||
~~
|
||||
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'Date'.
|
||||
|
||||
|
||||
|
||||
@@ -16,6 +16,6 @@ tests/cases/compiler/typeArgumentConstraintResolution1.ts(11,6): error TS2344: T
|
||||
function foo2<T extends Number>(test: string): T;
|
||||
function foo2<T extends String>(test: any): any { return null; }
|
||||
foo2<Date>(""); // Type Date does not satisfy the constraint 'Number' for type parameter 'T extends Number'
|
||||
~~~~
|
||||
!!! error TS2344: Type 'Date' does not satisfy the constraint 'Number'.
|
||||
~~
|
||||
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'Date'.
|
||||
|
||||
@@ -11,11 +11,11 @@ declare function foo(arg: (x: D) => number): string;
|
||||
declare function foo(arg: (x: C) => any): string;
|
||||
declare function foo(arg: (x: B) => any): number;
|
||||
|
||||
var result: number = foo(x => new G(x)); // No error, returns number
|
||||
var result: number = foo(x => new G(x)); // x has type D, new G(x) fails, so first overload is picked.
|
||||
|
||||
var result2: number = foo(x => new G<typeof x>(x)); // No error, returns number
|
||||
var result2: number = foo(x => new G<typeof x>(x)); // x has type D, new G(x) fails, so first overload is picked.
|
||||
|
||||
var result3: string = foo(x => { // returns string because the C overload is picked
|
||||
var y: G<typeof x>; // error that C does not satisfy constraint
|
||||
var result3: string = foo(x => { // x has type D
|
||||
var y: G<typeof x>; // error that D does not satisfy constraint, y is of type G<D>, entire call to foo is an error
|
||||
return y;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user