Skip to content

Commit 1738ee0

Browse files
author
Andy Hanson
committed
Always call getCandidateForOverloadFailure
1 parent b059135 commit 1738ee0

File tree

235 files changed

+1491
-1181
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

235 files changed

+1491
-1181
lines changed

Diff for: src/compiler/checker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19952,7 +19952,7 @@ namespace ts {
1995219952
}
1995319953
}
1995419954

19955-
return produceDiagnostics || !args ? resolveErrorCall(node) : getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray);
19955+
return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray);
1995619956

1995719957
function chooseOverload(candidates: Signature[], relation: Map<RelationComparisonResult>, signatureHelpTrailingComma = false) {
1995819958
candidateForArgumentError = undefined;

Diff for: tests/baselines/reference/argumentExpressionContextualTyping.types

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ baz(array); // Error
122122
baz(["string", 1, true, ...array]); // Error
123123
>baz(["string", 1, true, ...array]) : void
124124
>baz : (x: [string, number, boolean]) => void
125-
>["string", 1, true, ...array] : (string | number | boolean)[]
125+
>["string", 1, true, ...array] : [string, number, true, ...(string | number | boolean)[]]
126126
>"string" : "string"
127127
>1 : 1
128128
>true : true

Diff for: tests/baselines/reference/arrayAssignmentTest3.types

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class a {
1717

1818

1919
var xx = new a(null, 7, new B());
20-
>xx : any
21-
>new a(null, 7, new B()) : any
20+
>xx : a
21+
>new a(null, 7, new B()) : a
2222
>a : typeof a
2323
>null : null
2424
>7 : 7

Diff for: tests/baselines/reference/baseCheck.errors.txt

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
tests/cases/compiler/baseCheck.ts(9,18): error TS2552: Cannot find name 'loc'. Did you mean 'ELoc'?
22
tests/cases/compiler/baseCheck.ts(17,53): error TS2554: Expected 2 arguments, but got 1.
3-
tests/cases/compiler/baseCheck.ts(17,59): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
43
tests/cases/compiler/baseCheck.ts(18,62): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
54
tests/cases/compiler/baseCheck.ts(19,59): error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'.
6-
tests/cases/compiler/baseCheck.ts(19,68): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
75
tests/cases/compiler/baseCheck.ts(22,9): error TS2304: Cannot find name 'x'.
86
tests/cases/compiler/baseCheck.ts(23,7): error TS2304: Cannot find name 'x'.
97
tests/cases/compiler/baseCheck.ts(26,9): error TS2304: Cannot find name 'x'.
108

119

12-
==== tests/cases/compiler/baseCheck.ts (9 errors) ====
10+
==== tests/cases/compiler/baseCheck.ts (7 errors) ====
1311
class C { constructor(x: number, y: number) { } }
1412
class ELoc extends C {
1513
constructor(x: number) {
@@ -32,17 +30,18 @@ tests/cases/compiler/baseCheck.ts(26,9): error TS2304: Cannot find name 'x'.
3230
class D extends C { constructor(public z: number) { super(this.z) } } // too few params
3331
~~~~~~~~~~~~~
3432
!!! error TS2554: Expected 2 arguments, but got 1.
33+
<<<<<<< b059135c51ee93f8fb44dd70a2ca67674ff7a877
3534
!!! related TS6210 tests/cases/compiler/baseCheck.ts:1:34: An argument for 'y' was not provided.
3635
~~~~
3736
!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
37+
=======
38+
>>>>>>> Always call getCandidateForOverloadFailure
3839
class E extends C { constructor(public z: number) { super(0, this.z) } }
3940
~~~~
4041
!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
4142
class F extends C { constructor(public z: number) { super("hello", this.z) } } // first param type
4243
~~~~~~~
4344
!!! error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'.
44-
~~~~
45-
!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
4645

4746
function f() {
4847
if (x<10) {

Diff for: tests/baselines/reference/blockScopedSameNameFunctionDeclarationES5.types

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function foo(a: number) {
1616
>foo : { (): void; (): void; }
1717

1818
foo(10); // not ok
19-
>foo(10) : any
19+
>foo(10) : void
2020
>foo : { (): void; (): void; }
2121
>10 : 10
2222
}
@@ -29,12 +29,12 @@ function foo(a: number) {
2929
>foo : { (): void; (): void; }
3030

3131
foo(10); // not ok
32-
>foo(10) : any
32+
>foo(10) : void
3333
>foo : { (): void; (): void; }
3434
>10 : 10
3535
}
3636
foo(10); // not ok
37-
>foo(10) : any
37+
>foo(10) : void
3838
>foo : { (): void; (): void; }
3939
>10 : 10
4040

Diff for: tests/baselines/reference/blockScopedSameNameFunctionDeclarationES6.types

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function foo(a: number) {
1616
>foo : { (): void; (): void; }
1717

1818
foo(10); // not ok
19-
>foo(10) : any
19+
>foo(10) : void
2020
>foo : { (): void; (): void; }
2121
>10 : 10
2222
}
@@ -29,12 +29,12 @@ function foo(a: number) {
2929
>foo : { (): void; (): void; }
3030

3131
foo(10);// not ok
32-
>foo(10) : any
32+
>foo(10) : void
3333
>foo : { (): void; (): void; }
3434
>10 : 10
3535
}
3636
foo(10); // not ok
37-
>foo(10) : any
37+
>foo(10) : void
3838
>foo : { (): void; (): void; }
3939
>10 : 10
4040

Diff for: tests/baselines/reference/callGenericFunctionWithIncorrectNumberOfTypeArguments.types

+20-20
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ function f<T, U>(x: T, y: U): T { return null; }
99
>null : null
1010

1111
var r1 = f<number>(1, '');
12-
>r1 : any
13-
>f<number>(1, '') : any
12+
>r1 : number
13+
>f<number>(1, '') : number
1414
>f : <T, U>(x: T, y: U) => T
1515
>1 : 1
1616
>'' : ""
1717

1818
var r1b = f<number, string, number>(1, '');
19-
>r1b : any
20-
>f<number, string, number>(1, '') : any
19+
>r1b : number
20+
>f<number, string, number>(1, '') : number
2121
>f : <T, U>(x: T, y: U) => T
2222
>1 : 1
2323
>'' : ""
@@ -30,15 +30,15 @@ var f2 = <T, U>(x: T, y: U): T => { return null; }
3030
>null : null
3131

3232
var r2 = f2<number>(1, '');
33-
>r2 : any
34-
>f2<number>(1, '') : any
33+
>r2 : number
34+
>f2<number>(1, '') : number
3535
>f2 : <T, U>(x: T, y: U) => T
3636
>1 : 1
3737
>'' : ""
3838

3939
var r2b = f2<number, string, number>(1, '');
40-
>r2b : any
41-
>f2<number, string, number>(1, '') : any
40+
>r2b : number
41+
>f2<number, string, number>(1, '') : number
4242
>f2 : <T, U>(x: T, y: U) => T
4343
>1 : 1
4444
>'' : ""
@@ -49,15 +49,15 @@ var f3: { <T, U>(x: T, y: U): T; }
4949
>y : U
5050

5151
var r3 = f3<number>(1, '');
52-
>r3 : any
53-
>f3<number>(1, '') : any
52+
>r3 : number
53+
>f3<number>(1, '') : number
5454
>f3 : <T, U>(x: T, y: U) => T
5555
>1 : 1
5656
>'' : ""
5757

5858
var r3b = f3<number, string, number>(1, '');
59-
>r3b : any
60-
>f3<number, string, number>(1, '') : any
59+
>r3b : number
60+
>f3<number, string, number>(1, '') : number
6161
>f3 : <T, U>(x: T, y: U) => T
6262
>1 : 1
6363
>'' : ""
@@ -75,8 +75,8 @@ class C {
7575
}
7676
}
7777
var r4 = (new C()).f<number>(1, '');
78-
>r4 : any
79-
>(new C()).f<number>(1, '') : any
78+
>r4 : number
79+
>(new C()).f<number>(1, '') : number
8080
>(new C()).f : <T, U>(x: T, y: U) => T
8181
>(new C()) : C
8282
>new C() : C
@@ -86,8 +86,8 @@ var r4 = (new C()).f<number>(1, '');
8686
>'' : ""
8787

8888
var r4b = (new C()).f<number, string, number>(1, '');
89-
>r4b : any
90-
>(new C()).f<number, string, number>(1, '') : any
89+
>r4b : number
90+
>(new C()).f<number, string, number>(1, '') : number
9191
>(new C()).f : <T, U>(x: T, y: U) => T
9292
>(new C()) : C
9393
>new C() : C
@@ -106,17 +106,17 @@ var i: I;
106106
>i : I
107107

108108
var r5 = i.f<number>(1, '');
109-
>r5 : any
110-
>i.f<number>(1, '') : any
109+
>r5 : number
110+
>i.f<number>(1, '') : number
111111
>i.f : <T, U>(x: T, y: U) => T
112112
>i : I
113113
>f : <T, U>(x: T, y: U) => T
114114
>1 : 1
115115
>'' : ""
116116

117117
var r5b = i.f<number, string, number>(1, '');
118-
>r5b : any
119-
>i.f<number, string, number>(1, '') : any
118+
>r5b : number
119+
>i.f<number, string, number>(1, '') : number
120120
>i.f : <T, U>(x: T, y: U) => T
121121
>i : I
122122
>f : <T, U>(x: T, y: U) => T

Diff for: tests/baselines/reference/callOnInstance.errors.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
tests/cases/compiler/callOnInstance.ts(1,18): error TS2300: Duplicate identifier 'D'.
22
tests/cases/compiler/callOnInstance.ts(3,15): error TS2300: Duplicate identifier 'D'.
3+
tests/cases/compiler/callOnInstance.ts(7,19): error TS2350: Only a void function can be called with the 'new' keyword.
34
tests/cases/compiler/callOnInstance.ts(7,19): error TS2554: Expected 0 arguments, but got 1.
45
tests/cases/compiler/callOnInstance.ts(10,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'C' has no compatible call signatures.
56

67

7-
==== tests/cases/compiler/callOnInstance.ts (4 errors) ====
8+
==== tests/cases/compiler/callOnInstance.ts (5 errors) ====
89
declare function D(): string; // error
910
~
1011
!!! error TS2300: Duplicate identifier 'D'.
@@ -17,6 +18,8 @@ tests/cases/compiler/callOnInstance.ts(10,1): error TS2349: Cannot invoke an exp
1718

1819
var s2: string = (new D(1))();
1920
~~~~~~~~
21+
!!! error TS2350: Only a void function can be called with the 'new' keyword.
22+
~~~~~~~~
2023
!!! error TS2554: Expected 0 arguments, but got 1.
2124

2225
declare class C { constructor(value: number); }

Diff for: tests/baselines/reference/callOverloads1.errors.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
tests/cases/compiler/callOverloads1.ts(1,7): error TS2300: Duplicate identifier 'Foo'.
22
tests/cases/compiler/callOverloads1.ts(9,10): error TS2300: Duplicate identifier 'Foo'.
33
tests/cases/compiler/callOverloads1.ts(9,10): error TS2391: Function implementation is missing or not immediately following the declaration.
4+
tests/cases/compiler/callOverloads1.ts(13,10): error TS2350: Only a void function can be called with the 'new' keyword.
45
tests/cases/compiler/callOverloads1.ts(13,10): error TS2554: Expected 0 arguments, but got 1.
56

67

7-
==== tests/cases/compiler/callOverloads1.ts (4 errors) ====
8+
==== tests/cases/compiler/callOverloads1.ts (5 errors) ====
89
class Foo { // error
910
~~~
1011
!!! error TS2300: Duplicate identifier 'Foo'.
@@ -25,6 +26,8 @@ tests/cases/compiler/callOverloads1.ts(13,10): error TS2554: Expected 0 argument
2526

2627
var f1 = new Foo("hey");
2728
~~~~~~~~~~~~~~
29+
!!! error TS2350: Only a void function can be called with the 'new' keyword.
30+
~~~~~~~~~~~~~~
2831
!!! error TS2554: Expected 0 arguments, but got 1.
2932

3033

Diff for: tests/baselines/reference/callOverloads2.errors.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ tests/cases/compiler/callOverloads2.ts(11,10): error TS2389: Function implementa
44
tests/cases/compiler/callOverloads2.ts(11,10): error TS2393: Duplicate function implementation.
55
tests/cases/compiler/callOverloads2.ts(12,10): error TS2393: Duplicate function implementation.
66
tests/cases/compiler/callOverloads2.ts(14,10): error TS2391: Function implementation is missing or not immediately following the declaration.
7+
tests/cases/compiler/callOverloads2.ts(18,10): error TS2350: Only a void function can be called with the 'new' keyword.
78
tests/cases/compiler/callOverloads2.ts(18,10): error TS2554: Expected 0 arguments, but got 1.
89

910

10-
==== tests/cases/compiler/callOverloads2.ts (7 errors) ====
11+
==== tests/cases/compiler/callOverloads2.ts (8 errors) ====
1112
class Foo { // error
1213
~~~
1314
!!! error TS2300: Duplicate identifier 'Foo'.
@@ -39,6 +40,8 @@ tests/cases/compiler/callOverloads2.ts(18,10): error TS2554: Expected 0 argument
3940

4041
var f1 = new Foo("hey");
4142
~~~~~~~~~~~~~~
43+
!!! error TS2350: Only a void function can be called with the 'new' keyword.
44+
~~~~~~~~~~~~~~
4245
!!! error TS2554: Expected 0 arguments, but got 1.
4346

4447

Diff for: tests/baselines/reference/callSignaturesShouldBeResolvedBeforeSpecialization.types

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function foo() {
1919
>"expects boolean instead of string" : "expects boolean instead of string"
2020

2121
test(true); // should error - string expected
22-
>test(true) : any
22+
>test(true) : void
2323
>test : I1<string>
2424
>true : true
2525
}

Diff for: tests/baselines/reference/callWithWrongNumberOfTypeArguments.types

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ function f<T, U>() { }
33
>f : <T, U>() => void
44

55
f<number>();
6-
>f<number>() : any
6+
>f<number>() : void
77
>f : <T, U>() => void
88

99
f<number, string>();
1010
>f<number, string>() : void
1111
>f : <T, U>() => void
1212

1313
f<number, string, number>();
14-
>f<number, string, number>() : any
14+
>f<number, string, number>() : void
1515
>f : <T, U>() => void
1616

Diff for: tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.errors.txt

+22-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1+
<<<<<<< b059135c51ee93f8fb44dd70a2ca67674ff7a877
12
tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts(19,64): error TS2741: Property 'z' is missing in type 'B' but required in type 'C'.
3+
=======
4+
tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts(19,59): error TS2345: Argument of type '(c: C) => B' is not assignable to parameter of type '(x: C) => C'.
5+
Type 'B' is not assignable to type 'C'.
6+
Property 'z' is missing in type 'B'.
7+
tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts(19,76): error TS2345: Argument of type '(b: C) => A' is not assignable to parameter of type '(x: C) => C'.
8+
Type 'A' is not assignable to type 'C'.
9+
Property 'z' is missing in type 'A'.
10+
>>>>>>> Always call getCandidateForOverloadFailure
211

312

4-
==== tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts (1 errors) ====
13+
==== tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts (2 errors) ====
514
class Chain<T extends A> {
615
constructor(public value: T) { }
716
then<S extends T>(cb: (x: T) => S): Chain<S> {
@@ -21,7 +30,18 @@ tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParamete
2130

2231
// Ok to go down the chain, but error to try to climb back up
2332
(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B).then(b => new A);
33+
<<<<<<< b059135c51ee93f8fb44dd70a2ca67674ff7a877
2434
~~~~~
2535
!!! error TS2741: Property 'z' is missing in type 'B' but required in type 'C'.
2636
!!! related TS2728 tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts:15:5: 'z' is declared here.
27-
!!! related TS6502 tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts:3:27: The expected type comes from the return type of this signature.
37+
!!! related TS6502 tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts:3:27: The expected type comes from the return type of this signature.
38+
=======
39+
~~~~~~~~~~
40+
!!! error TS2345: Argument of type '(c: C) => B' is not assignable to parameter of type '(x: C) => C'.
41+
!!! error TS2345: Type 'B' is not assignable to type 'C'.
42+
!!! error TS2345: Property 'z' is missing in type 'B'.
43+
~~~~~~~~~~
44+
!!! error TS2345: Argument of type '(b: C) => A' is not assignable to parameter of type '(x: C) => C'.
45+
!!! error TS2345: Type 'A' is not assignable to type 'C'.
46+
!!! error TS2345: Property 'z' is missing in type 'A'.
47+
>>>>>>> Always call getCandidateForOverloadFailure

Diff for: tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.symbols

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class C extends B {
4646

4747
// Ok to go down the chain, but error to try to climb back up
4848
(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B).then(b => new A);
49+
>(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B).then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 1, 36))
4950
>(new Chain(new A)).then(a => new B).then(b => new C).then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 1, 36))
5051
>(new Chain(new A)).then(a => new B).then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 1, 36))
5152
>(new Chain(new A)).then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 1, 36))
@@ -60,6 +61,7 @@ class C extends B {
6061
>then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 1, 36))
6162
>c : Symbol(c, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 18, 58))
6263
>B : Symbol(B, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 9, 1))
64+
>then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 1, 36))
6365
>b : Symbol(b, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 18, 75))
6466
>A : Symbol(A, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 5, 1))
6567

Diff for: tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.types

+6-6
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ class C extends B {
3838

3939
// Ok to go down the chain, but error to try to climb back up
4040
(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B).then(b => new A);
41-
>(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B).then(b => new A) : any
42-
>(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B).then : any
43-
>(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B) : any
41+
>(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B).then(b => new A) : Chain<C>
42+
>(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B).then : <S extends C>(cb: (x: C) => S) => Chain<S>
43+
>(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B) : Chain<C>
4444
>(new Chain(new A)).then(a => new B).then(b => new C).then : <S extends C>(cb: (x: C) => S) => Chain<S>
4545
>(new Chain(new A)).then(a => new B).then(b => new C) : Chain<C>
4646
>(new Chain(new A)).then(a => new B).then : <S extends B>(cb: (x: B) => S) => Chain<S>
@@ -66,9 +66,9 @@ class C extends B {
6666
>c : C
6767
>new B : B
6868
>B : typeof B
69-
>then : any
70-
>b => new A : (b: any) => A
71-
>b : any
69+
>then : <S extends C>(cb: (x: C) => S) => Chain<S>
70+
>b => new A : (b: C) => A
71+
>b : C
7272
>new A : A
7373
>A : typeof A
7474

0 commit comments

Comments
 (0)