Skip to content

Commit 329d6e2

Browse files
committed
merge with master
2 parents 03cb645 + 3e89452 commit 329d6e2

File tree

49 files changed

+692
-382
lines changed

Some content is hidden

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

49 files changed

+692
-382
lines changed

src/compiler/checker.ts

Lines changed: 295 additions & 116 deletions
Large diffs are not rendered by default.

src/compiler/core.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,12 @@ module ts {
274274
};
275275
}
276276

277+
export function concatenateDiagnosticMessageChains(headChain: DiagnosticMessageChain, tailChain: DiagnosticMessageChain): DiagnosticMessageChain {
278+
Debug.assert(!headChain.next);
279+
headChain.next = tailChain;
280+
return headChain;
281+
}
282+
277283
export function flattenDiagnosticChain(file: SourceFile, start: number, length: number, diagnosticChain: DiagnosticMessageChain, newLine: string): Diagnostic {
278284
Debug.assert(start >= 0, "start must be non-negative, is " + start);
279285
Debug.assert(length >= 0, "length must be non-negative, is " + length);

src/compiler/diagnosticInformationMap.generated.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,9 @@ module ts {
271271
Left_hand_side_of_assignment_expression_cannot_be_a_constant: { code: 2450, category: DiagnosticCategory.Error, key: "Left-hand side of assignment expression cannot be a constant.", isEarly: true },
272272
Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: DiagnosticCategory.Error, key: "Cannot redeclare block-scoped variable '{0}'.", isEarly: true },
273273
An_enum_member_cannot_have_a_numeric_name: { code: 2452, category: DiagnosticCategory.Error, key: "An enum member cannot have a numeric name." },
274+
The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly_Colon: { code: 2453, category: DiagnosticCategory.Error, key: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly:" },
275+
Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0_Colon: { code: 2454, category: DiagnosticCategory.Error, key: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}':" },
276+
Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { code: 2455, category: DiagnosticCategory.Error, key: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'." },
274277
Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
275278
Type_parameter_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4001, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using name '{1}' from private module '{2}'." },
276279
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },

src/compiler/diagnosticMessages.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,18 @@
10801080
"category": "Error",
10811081
"code": 2452
10821082
},
1083+
"The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly:": {
1084+
"category": "Error",
1085+
"code": 2453
1086+
},
1087+
"Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}':": {
1088+
"category": "Error",
1089+
"code": 2454
1090+
},
1091+
"Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'.": {
1092+
"category": "Error",
1093+
"code": 2455
1094+
},
10831095

10841096
"Import declaration '{0}' is using private name '{1}'.": {
10851097
"category": "Error",

src/compiler/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ module ts {
766766
}
767767

768768
export enum SymbolFlags {
769-
FunctionScopedVariable = 0x00000001, // Variable (var) or parameter
769+
FunctionScopedVariable = 0x00000001, // Variable (var) or parameter
770770
Property = 0x00000002, // Property or enum member
771771
EnumMember = 0x00000004, // Enum member
772772
Function = 0x00000008, // Function
@@ -1034,6 +1034,8 @@ module ts {
10341034
inferenceCount: number; // Incremented for every inference made (whether new or not)
10351035
inferences: Type[][]; // Inferences made for each type parameter
10361036
inferredTypes: Type[]; // Inferred type for each type parameter
1037+
failedTypeParameterIndex?: number; // Index of type parameter for which inference failed
1038+
// It is optional because in contextual signature instantiation, nothing fails
10371039
}
10381040

10391041
export interface DiagnosticMessage {

src/services/services.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3836,7 +3836,7 @@ module ts {
38363836
if (symbol.getFlags() && (SymbolFlags.Property | SymbolFlags.Method)) {
38373837
var privateDeclaration = forEach(symbol.getDeclarations(), d => (d.flags & NodeFlags.Private) ? d : undefined);
38383838
if (privateDeclaration) {
3839-
return privateDeclaration.parent;
3839+
return getAncestor(privateDeclaration, SyntaxKind.ClassDeclaration);
38403840
}
38413841
}
38423842

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts(2,22): error TS2339: Property 'foo' does not exist on type 'string'.
2-
tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts(3,10): error TS2346: Supplied parameters do not match any signature of call target.
2+
tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts(3,10): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly:
3+
Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'.
34

45

56
==== tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts (2 errors) ====
@@ -8,5 +9,6 @@ tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts(3,10): error TS
89
~~~
910
!!! error TS2339: Property 'foo' does not exist on type 'string'.
1011
var r9 = f10('', () => (a => a.foo), 1); // error
11-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12-
!!! error TS2346: Supplied parameters do not match any signature of call target.
12+
~~~
13+
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly:
14+
!!! error TS2453: Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'.

tests/baselines/reference/defaultBestCommonTypesHaveDecls.errors.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(2,6): error TS2339: Property 'length' does not exist on type '{}'.
22
tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(5,6): error TS2339: Property 'length' does not exist on type 'Object'.
3-
tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(8,14): error TS2346: Supplied parameters do not match any signature of call target.
3+
tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(8,14): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly:
4+
Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'.
45

56

67
==== tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts (3 errors) ====
@@ -16,8 +17,9 @@ tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(8,14): error TS2346: Sup
1617

1718
function concat<T>(x: T, y: T): T { return null; }
1819
var result = concat(1, ""); // error
19-
~~~~~~~~~~~~~
20-
!!! error TS2346: Supplied parameters do not match any signature of call target.
20+
~~~~~~
21+
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly:
22+
!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'.
2123
var elementCount = result.length;
2224

2325
function concat2<T, U>(x: T, y: U) { return null; }
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
tests/cases/compiler/fixTypeParameterInSignatureWithRestParameters.ts(2,1): error TS2346: Supplied parameters do not match any signature of call target.
1+
tests/cases/compiler/fixTypeParameterInSignatureWithRestParameters.ts(2,1): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly:
2+
Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'.
23

34

45
==== tests/cases/compiler/fixTypeParameterInSignatureWithRestParameters.ts (1 errors) ====
56
function bar<T>(item1: T, item2: T) { }
67
bar(1, ""); // Should be ok
7-
~~~~~~~~~~
8-
!!! error TS2346: Supplied parameters do not match any signature of call target.
8+
~~~
9+
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly:
10+
!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'.

tests/baselines/reference/genericCallWithFunctionTypedArguments.errors.txt

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(26,18): error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => number'.
2-
Type 'string' is not assignable to type 'number'.
3-
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(30,15): error TS2346: Supplied parameters do not match any signature of call target.
4-
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(33,15): error TS2346: Supplied parameters do not match any signature of call target.
5-
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(34,16): error TS2346: Supplied parameters do not match any signature of call target.
6-
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(35,23): error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => number'.
7-
Type 'string' is not assignable to type 'number'.
1+
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(26,10): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly:
2+
Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'.
3+
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(30,15): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly:
4+
Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'T'.
5+
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(33,15): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly:
6+
Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'T'.
7+
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(34,16): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly:
8+
Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'T'.
9+
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(35,15): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly:
10+
Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'.
811

912

1013
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts (5 errors) ====
@@ -34,25 +37,28 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFun
3437
var r7 = foo3(1, <Z>(a: Z) => '', ''); // string
3538

3639
var r8 = foo3(1, function (a) { return '' }, 1); // error
37-
~~~~~~~~~~~~~~~~~~~~~~~~~~
38-
!!! error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => number'.
39-
!!! error TS2345: Type 'string' is not assignable to type 'number'.
40+
~~~~
41+
!!! error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly:
42+
!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'.
4043
var r9 = foo3<number, string>(1, (a) => '', ''); // string
4144

4245
function other<T, U>(t: T, u: U) {
4346
var r10 = foo2(1, (x: T) => ''); // error
44-
~~~~~~~~~~~~~~~~~~~~~
45-
!!! error TS2346: Supplied parameters do not match any signature of call target.
47+
~~~~
48+
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly:
49+
!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'T'.
4650
var r10 = foo2(1, (x) => ''); // string
4751

4852
var r11 = foo3(1, (x: T) => '', ''); // error
49-
~~~~~~~~~~~~~~~~~~~~~~~~~
50-
!!! error TS2346: Supplied parameters do not match any signature of call target.
53+
~~~~
54+
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly:
55+
!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'T'.
5156
var r11b = foo3(1, (x: T) => '', 1); // error
52-
~~~~~~~~~~~~~~~~~~~~~~~~
53-
!!! error TS2346: Supplied parameters do not match any signature of call target.
57+
~~~~
58+
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly:
59+
!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'T'.
5460
var r12 = foo3(1, function (a) { return '' }, 1); // error
55-
~~~~~~~~~~~~~~~~~~~~~~~~~~
56-
!!! error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => number'.
57-
!!! error TS2345: Type 'string' is not assignable to type 'number'.
61+
~~~~
62+
!!! error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly:
63+
!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'.
5864
}

tests/baselines/reference/genericCallWithFunctionTypedArguments2.errors.txt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts(29,10): error TS2346: Supplied parameters do not match any signature of call target.
2-
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts(40,10): error TS2346: Supplied parameters do not match any signature of call target.
1+
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts(29,10): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly:
2+
Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'.
3+
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts(40,10): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly:
4+
Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'.
35

46

57
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts (2 errors) ====
@@ -32,8 +34,9 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFun
3234
}
3335

3436
var r4 = foo2(1, i2); // error
35-
~~~~~~~~~~~
36-
!!! error TS2346: Supplied parameters do not match any signature of call target.
37+
~~~~
38+
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly:
39+
!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'.
3740
var r4b = foo2(1, a); // any
3841
var r5 = foo2(1, i); // any
3942
var r6 = foo2<string, string>('', i2); // string
@@ -45,6 +48,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFun
4548
var r7 = foo3(null, i, ''); // any
4649
var r7b = foo3(null, a, ''); // any
4750
var r8 = foo3(1, i2, 1); // error
48-
~~~~~~~~~~~~~~
49-
!!! error TS2346: Supplied parameters do not match any signature of call target.
51+
~~~~
52+
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly:
53+
!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'.
5054
var r9 = foo3<string, string>('', i2, ''); // string

0 commit comments

Comments
 (0)