Skip to content

Commit d14228e

Browse files
committed
More PR feedback
1 parent d1079e4 commit d14228e

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

src/compiler/checker.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ module ts {
130130
var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
131131
var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
132132
var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
133-
var typeArgumentInferenceFailureType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
133+
var inferenceFailureType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
134134

135135
var anySignature = createSignature(undefined, undefined, emptyArray, anyType, 0, false, false);
136136
var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, 0, false, false);
@@ -3797,7 +3797,7 @@ module ts {
37973797
var score = 0;
37983798
var downfallType: Type = undefined;
37993799
for (var j = 0; j < types.length; j++) {
3800-
if (types[i] === types[j] || isTypeSubtypeOf(types[j], types[i])) {
3800+
if (isTypeSubtypeOf(types[j], types[i])) {
38013801
score++;
38023802
}
38033803
else if (!downfallType) {
@@ -4087,14 +4087,14 @@ module ts {
40874087
if (inferences.length) {
40884088
// Infer widened union or supertype, or the undefined type for no common supertype
40894089
var unionOrSuperType = context.inferUnionTypes ? getUnionType(inferences) : getCommonSupertype(inferences);
4090-
inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : typeArgumentInferenceFailureType;
4090+
inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : inferenceFailureType;
40914091
}
40924092
else {
40934093
// Infer the empty object type when no inferences were made
40944094
inferredType = emptyObjectType;
40954095
}
40964096

4097-
if (inferredType !== typeArgumentInferenceFailureType) {
4097+
if (inferredType !== inferenceFailureType) {
40984098
var constraint = getConstraintOfTypeParameter(context.typeParameters[index]);
40994099
inferredType = constraint && !isTypeAssignableTo(inferredType, constraint) ? constraint : inferredType;
41004100
}
@@ -5184,12 +5184,12 @@ module ts {
51845184
}
51855185
}
51865186
var inferredTypes = getInferredTypes(context);
5187-
// Inference has failed if the typeArgumentInferenceFailureType type is in list of inferences
5188-
context.failureIndex = indexOf(inferredTypes, typeArgumentInferenceFailureType);
5187+
// Inference has failed if the inferenceFailureType type is in list of inferences
5188+
context.failedTypeParameterIndex = indexOf(inferredTypes, inferenceFailureType);
51895189

5190-
// Wipe out the typeArgumentInferenceFailureType from the array so that error recovery can work properly
5190+
// Wipe out the inferenceFailureType from the array so that error recovery can work properly
51915191
for (var i = 0; i < inferredTypes.length; i++) {
5192-
if (inferredTypes[i] === typeArgumentInferenceFailureType) {
5192+
if (inferredTypes[i] === inferenceFailureType) {
51935193
inferredTypes[i] = unknownType;
51945194
}
51955195
}
@@ -5314,7 +5314,7 @@ module ts {
53145314
// skip the checkApplicableSignature check.
53155315
if (candidateForArgumentError) {
53165316
// excludeArgument is undefined, in this case also equivalent to [undefined, undefined, ...]
5317-
// The importance of exlcludeArgument is to prevent us from typing function expression parameters
5317+
// The importance of excludeArgument is to prevent us from typing function expression parameters
53185318
// in arguments too early. If possible, we'd like to only type them once we know the correct
53195319
// overload. However, this matters for the case where the call is correct. When the call is
53205320
// an error, we don't need to exclude any arguments, although it would cause no harm to do so.
@@ -5325,9 +5325,9 @@ module ts {
53255325
checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], /*reportErrors*/ true)
53265326
}
53275327
else {
5328-
Debug.assert(resultOfFailedInference.failureIndex >= 0);
5329-
var failedTypeParameter = candidateForTypeArgumentError.typeParameters[resultOfFailedInference.failureIndex];
5330-
var inferenceCandidates = resultOfFailedInference.inferences[resultOfFailedInference.failureIndex];
5328+
Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0);
5329+
var failedTypeParameter = candidateForTypeArgumentError.typeParameters[resultOfFailedInference.failedTypeParameterIndex];
5330+
var inferenceCandidates = resultOfFailedInference.inferences[resultOfFailedInference.failedTypeParameterIndex];
53315331

53325332
var diagnosticChainHead = chainDiagnosticMessages(/*details*/ undefined, // details will be provided by call to reportNoCommonSupertypeError
53335333
Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly_Colon,
@@ -5375,7 +5375,7 @@ module ts {
53755375
}
53765376
else {
53775377
inferenceResult = inferTypeArguments(candidate, args, excludeArgument);
5378-
typeArgumentsAreValid = inferenceResult.failureIndex < 0;
5378+
typeArgumentsAreValid = inferenceResult.failedTypeParameterIndex < 0;
53795379
typeArgumentTypes = inferenceResult.inferredTypes;
53805380
}
53815381
if (!typeArgumentsAreValid) {

src/compiler/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ 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-
failureIndex?: number; // Index of type parameter for which inference failed
1037+
failedTypeParameterIndex?: number; // Index of type parameter for which inference failed
10381038
// It is optional because in contextual signature instantiation, nothing fails
10391039
}
10401040

0 commit comments

Comments
 (0)