Removed redundant check.

This commit is contained in:
Eric Traut 2022-05-10 21:31:14 -07:00
parent 29f1b15cb7
commit 977db37df2
2 changed files with 11 additions and 16 deletions

View File

@ -19740,8 +19740,6 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
}
}
// If we're using ReverseTypeVarMatching and the source is a TypeVar,
// the logic below will handle this case.
if ((flags & CanAssignFlags.ReverseTypeVarMatching) === 0 || !isTypeVar(srcType)) {
if (
!canAssignTypeToTypeVar(
@ -20938,8 +20936,6 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
return false;
}
// We may need to reverse the type var mapping to populate the type
// var map of the
let specializedSrcType = srcType;
let specializedDestType = destType;
let reverseMatchingFailed = false;
@ -20966,18 +20962,16 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
specializedSrcType = applySolvedTypeVars(srcType, srcTypeVarContext);
if (requiresSpecialization(specializedSrcType)) {
if (requiresSpecialization(specializedSrcType)) {
reverseMatchingFailed = !canAssignType(
specializedSrcType,
specializedDestType,
/* diag */ undefined,
srcTypeVarContext,
(flags & ~CanAssignFlags.ReverseTypeVarMatching) | CanAssignFlags.IgnoreTypeVarScope,
recursionCount
);
reverseMatchingFailed = !canAssignType(
specializedSrcType,
specializedDestType,
/* diag */ undefined,
srcTypeVarContext,
(flags & ~CanAssignFlags.ReverseTypeVarMatching) | CanAssignFlags.IgnoreTypeVarScope,
recursionCount
);
specializedSrcType = applySolvedTypeVars(srcType, srcTypeVarContext);
}
specializedSrcType = applySolvedTypeVars(srcType, srcTypeVarContext);
}
if (reverseMatchingFailed) {

View File

@ -128,7 +128,8 @@ export function createTypeEvaluatorWithTracker(
run('getCallSignatureInfo', () => typeEvaluator.getCallSignatureInfo(n, i, a), n),
getAbstractMethods: (c) => run('getAbstractMethods', () => typeEvaluator.getAbstractMethods(c), c),
narrowConstrainedTypeVar: typeEvaluator.narrowConstrainedTypeVar,
canAssignType: (d, s, a, m, f) => run('canAssignType', () => typeEvaluator.canAssignType(d, s, a, m, f), d),
canAssignType: (d, s, a, c, f, r) =>
run('canAssignType', () => typeEvaluator.canAssignType(d, s, a, c, f, r), d),
canOverrideMethod: (b, o, d, e) =>
run('canOverrideMethod', () => typeEvaluator.canOverrideMethod(b, o, d, e), o),
assignTypeToExpression: typeEvaluator.assignTypeToExpression,