@zzzen/pyright-internal 1.2.0-dev.20220828 → 1.2.0-dev.20220904

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/analyzer/binder.js +19 -22
  2. package/dist/analyzer/binder.js.map +1 -1
  3. package/dist/analyzer/checker.js +13 -0
  4. package/dist/analyzer/checker.js.map +1 -1
  5. package/dist/analyzer/patternMatching.js +10 -0
  6. package/dist/analyzer/patternMatching.js.map +1 -1
  7. package/dist/analyzer/program.d.ts +1 -0
  8. package/dist/analyzer/program.js +7 -3
  9. package/dist/analyzer/program.js.map +1 -1
  10. package/dist/analyzer/service.d.ts +1 -1
  11. package/dist/analyzer/service.js +3 -1
  12. package/dist/analyzer/service.js.map +1 -1
  13. package/dist/analyzer/sourceFile.d.ts +2 -1
  14. package/dist/analyzer/sourceFile.js +4 -3
  15. package/dist/analyzer/sourceFile.js.map +1 -1
  16. package/dist/analyzer/typeEvaluator.js +98 -56
  17. package/dist/analyzer/typeEvaluator.js.map +1 -1
  18. package/dist/analyzer/typeGuards.js +6 -5
  19. package/dist/analyzer/typeGuards.js.map +1 -1
  20. package/dist/analyzer/typeUtils.d.ts +1 -1
  21. package/dist/analyzer/typeUtils.js +2 -2
  22. package/dist/analyzer/typeUtils.js.map +1 -1
  23. package/dist/languageServerBase.d.ts +1 -1
  24. package/dist/languageServerBase.js +22 -17
  25. package/dist/languageServerBase.js.map +1 -1
  26. package/dist/tests/checker.test.js +2 -2
  27. package/dist/tests/ipythonMode.test.js +91 -0
  28. package/dist/tests/ipythonMode.test.js.map +1 -1
  29. package/dist/tests/typeEvaluator1.test.js +5 -1
  30. package/dist/tests/typeEvaluator1.test.js.map +1 -1
  31. package/dist/tests/typeEvaluator2.test.js +5 -1
  32. package/dist/tests/typeEvaluator2.test.js.map +1 -1
  33. package/dist/tests/typeEvaluator3.test.js +6 -0
  34. package/dist/tests/typeEvaluator3.test.js.map +1 -1
  35. package/dist/tests/typeEvaluator4.test.js +5 -1
  36. package/dist/tests/typeEvaluator4.test.js.map +1 -1
  37. package/package.json +1 -1
@@ -699,6 +699,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
699
699
  /* allowSpeculativeCaching */ true);
700
700
  if (expectedType && !(0, types_1.isAnyOrUnknown)(expectedType) && !(0, types_1.isNever)(expectedType)) {
701
701
  expectedTypeCache.set(node.id, expectedType);
702
+ if (!typeResult.isIncomplete && !typeResult.expectedTypeDiagAddendum) {
703
+ const diag = new diagnostic_1.DiagnosticAddendum();
704
+ if (!assignType(expectedType, typeResult.type, diag)) {
705
+ typeResult.expectedTypeDiagAddendum = diag;
706
+ diag.addTextRange(node);
707
+ }
708
+ }
702
709
  }
703
710
  if (printExpressionTypes) {
704
711
  printExpressionSpaceCount--;
@@ -3857,7 +3864,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3857
3864
  }
3858
3865
  }
3859
3866
  if (enforceTargetType) {
3860
- let effectiveType = concreteSubtype;
3867
+ let effectiveType = subtype;
3861
3868
  // If the code is patching a method (defined on the class)
3862
3869
  // with an object-level function, strip the "self" parameter
3863
3870
  // off the original type. This is sometimes done for test
@@ -4736,19 +4743,21 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
4736
4743
  });
4737
4744
  effectiveExpectedType = matchingSubtype;
4738
4745
  }
4746
+ let expectedTypeDiagAddendum;
4739
4747
  if (effectiveExpectedType) {
4740
4748
  const result = getTypeOfTupleExpected(node, effectiveExpectedType);
4741
- if (result) {
4749
+ if (result && !result.typeErrors) {
4742
4750
  return result;
4743
4751
  }
4752
+ expectedTypeDiagAddendum = result === null || result === void 0 ? void 0 : result.expectedTypeDiagAddendum;
4744
4753
  }
4745
- const resultType = getTypeOfTupleInferred(node);
4754
+ const typeResult = getTypeOfTupleInferred(node);
4746
4755
  // If there was an expected type of Any, replace the resulting type
4747
4756
  // with Any rather than return a type with unknowns.
4748
4757
  if (expectedTypeContainsAny) {
4749
- resultType.type = types_1.AnyType.create();
4758
+ typeResult.type = types_1.AnyType.create();
4750
4759
  }
4751
- return resultType;
4760
+ return { ...typeResult, expectedTypeDiagAddendum };
4752
4761
  }
4753
4762
  function getTypeOfTupleExpected(node, expectedType) {
4754
4763
  expectedType = (0, typeUtils_1.transformPossibleRecursiveTypeAlias)(expectedType);
@@ -4792,7 +4801,17 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
4792
4801
  /* flags */ undefined, index < expectedTypes.length ? expectedTypes[index] : undefined));
4793
4802
  const type = (0, typeUtils_1.convertToInstance)((0, typeUtils_1.specializeTupleClass)(tupleClassType, buildTupleTypesList(entryTypeResults),
4794
4803
  /* isTypeArgumentExplicit */ true));
4795
- return { type };
4804
+ // Copy any expected type diag addenda for precision error reporting.
4805
+ let expectedTypeDiagAddendum;
4806
+ if (entryTypeResults.some((result) => result.expectedTypeDiagAddendum)) {
4807
+ expectedTypeDiagAddendum = new diagnostic_1.DiagnosticAddendum();
4808
+ entryTypeResults.forEach((result) => {
4809
+ if (result.expectedTypeDiagAddendum) {
4810
+ expectedTypeDiagAddendum.addAddendum(result.expectedTypeDiagAddendum);
4811
+ }
4812
+ });
4813
+ }
4814
+ return { type, expectedTypeDiagAddendum };
4796
4815
  }
4797
4816
  function getTypeOfTupleInferred(node) {
4798
4817
  const entryTypeResults = node.expressions.map((expr) => getTypeOfExpression(expr));
@@ -5815,8 +5834,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
5815
5834
  // the call is a constructor but the proper TypeVar scope has been lost.
5816
5835
  // We'll add a wildcard TypeVar scope here. This is a bit of a hack and
5817
5836
  // we may need to revisit this in the future.
5818
- if (!effectiveTypeVarContext.getSolveForScopes() &&
5819
- types_1.FunctionType.isConstructorMethod(expandedSubtype)) {
5837
+ if (types_1.FunctionType.isConstructorMethod(expandedSubtype)) {
5820
5838
  effectiveTypeVarContext.addSolveForScope(types_1.WildcardTypeVarScopeId);
5821
5839
  }
5822
5840
  }
@@ -6807,12 +6825,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
6807
6825
  // types of each argument expression and validates that the resulting type is
6808
6826
  // compatible with the declared type of the corresponding parameter.
6809
6827
  function validateFunctionArgumentTypesWithExpectedType(errorNode, matchResults, typeVarContext, skipUnknownArgCheck = false, expectedType) {
6828
+ var _a;
6810
6829
  const type = matchResults.overload;
6811
6830
  if (!expectedType ||
6812
6831
  (0, types_1.isAnyOrUnknown)(expectedType) ||
6813
6832
  (0, types_1.isNever)(expectedType) ||
6814
6833
  (0, typeUtils_1.requiresSpecialization)(expectedType) ||
6815
- !type.details.declaredReturnType) {
6834
+ !type.details.declaredReturnType ||
6835
+ !(0, typeUtils_1.requiresSpecialization)((_a = types_1.FunctionType.getSpecializedReturnType(type)) !== null && _a !== void 0 ? _a : types_1.UnknownType.create())) {
6816
6836
  return validateFunctionArgumentTypes(errorNode, matchResults, typeVarContext, skipUnknownArgCheck);
6817
6837
  }
6818
6838
  const effectiveReturnType = getFunctionEffectiveReturnType(type);
@@ -8673,13 +8693,16 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8673
8693
  });
8674
8694
  effectiveExpectedType = matchingSubtype;
8675
8695
  }
8696
+ let expectedTypeDiagAddendum;
8676
8697
  if (effectiveExpectedType) {
8677
8698
  const result = getTypeOfListOrSetExpected(node, effectiveExpectedType);
8678
- if (result) {
8699
+ if (result && !result.typeErrors) {
8679
8700
  return result;
8680
8701
  }
8702
+ expectedTypeDiagAddendum = result === null || result === void 0 ? void 0 : result.expectedTypeDiagAddendum;
8681
8703
  }
8682
- return getTypeOfListOrSetInferred(node, /* hasExpectedType */ expectedType !== undefined);
8704
+ const typeResult = getTypeOfListOrSetInferred(node, /* hasExpectedType */ expectedType !== undefined);
8705
+ return { ...typeResult, expectedTypeDiagAddendum };
8683
8706
  }
8684
8707
  // Attempts to determine the type of a list or set statement based on an expected type.
8685
8708
  // Returns undefined if that type cannot be honored.
@@ -8705,6 +8728,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8705
8728
  }
8706
8729
  const expectedEntryType = specializedListOrSet.typeArguments[0];
8707
8730
  const entryTypes = [];
8731
+ const expectedTypeDiagAddendum = new diagnostic_1.DiagnosticAddendum();
8708
8732
  node.entries.forEach((entry) => {
8709
8733
  let entryTypeResult;
8710
8734
  if (entry.nodeType === 32 /* ListComprehension */) {
@@ -8720,15 +8744,18 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8720
8744
  if (entryTypeResult.typeErrors) {
8721
8745
  typeErrors = true;
8722
8746
  }
8747
+ if (entryTypeResult.expectedTypeDiagAddendum) {
8748
+ expectedTypeDiagAddendum.addAddendum(entryTypeResult.expectedTypeDiagAddendum);
8749
+ }
8723
8750
  });
8724
8751
  const isExpectedTypeListOrSet = (0, types_1.isClassInstance)(expectedType) && types_1.ClassType.isBuiltIn(expectedType, builtInClassName);
8725
8752
  const specializedEntryType = inferTypeArgFromExpectedType(expectedEntryType, entryTypes,
8726
8753
  /* isNarrowable */ !isExpectedTypeListOrSet);
8727
8754
  if (!specializedEntryType) {
8728
- return undefined;
8755
+ return { type: types_1.UnknownType.create(), isIncomplete, typeErrors: true, expectedTypeDiagAddendum };
8729
8756
  }
8730
8757
  const type = getBuiltInObject(node, builtInClassName, [specializedEntryType]);
8731
- return { type, isIncomplete, typeErrors };
8758
+ return { type, isIncomplete, typeErrors, expectedTypeDiagAddendum };
8732
8759
  }
8733
8760
  // Attempts to infer the type of a list or set statement with no "expected type".
8734
8761
  function getTypeOfListOrSetInferred(node, hasExpectedType) {
@@ -10366,6 +10393,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
10366
10393
  node.arguments.forEach((arg) => {
10367
10394
  // Ignore unpacked arguments.
10368
10395
  if (arg.argumentCategory !== 0 /* Simple */) {
10396
+ // Evaluate the expression's type so symbols are marked accessed
10397
+ // and errors are reported.
10398
+ getTypeOfExpression(arg.valueExpression);
10369
10399
  return;
10370
10400
  }
10371
10401
  if (!arg.name) {
@@ -10633,7 +10663,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
10633
10663
  if (metaclassNode) {
10634
10664
  const metaclassType = getTypeOfExpression(metaclassNode, exprFlags).type;
10635
10665
  if ((0, types_1.isInstantiableClass)(metaclassType) || (0, types_1.isUnknown)(metaclassType)) {
10636
- if ((0, typeUtils_1.requiresSpecialization)(metaclassType)) {
10666
+ if ((0, typeUtils_1.requiresSpecialization)(metaclassType, /* ignorePseudoGeneric */ true)) {
10637
10667
  addDiagnostic(fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.metaclassIsGeneric(), metaclassNode);
10638
10668
  }
10639
10669
  classType.details.declaredMetaclass = metaclassType;
@@ -10699,25 +10729,29 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
10699
10729
  // See if there's already a non-synthesized __init__ method.
10700
10730
  // We shouldn't override it.
10701
10731
  if (!skipSynthesizedInit) {
10702
- const initSymbol = (0, typeUtils_1.lookUpClassMember)(classType, '__init__', 2 /* SkipBaseClasses */);
10732
+ const initSymbol = (0, typeUtils_1.lookUpClassMember)(classType, '__init__', 4 /* SkipObjectBaseClass */);
10703
10733
  if (initSymbol) {
10704
- const initSymbolType = getTypeOfMember(initSymbol);
10705
- if ((0, types_1.isFunction)(initSymbolType)) {
10706
- if (!types_1.FunctionType.isSynthesizedMethod(initSymbolType)) {
10734
+ if (!(0, types_1.isClass)(initSymbol.classType) || !types_1.ClassType.isBuiltIn(initSymbol.classType, 'NamedTuple')) {
10735
+ const initSymbolType = getTypeOfMember(initSymbol);
10736
+ if ((0, types_1.isFunction)(initSymbolType)) {
10737
+ if (!types_1.FunctionType.isSynthesizedMethod(initSymbolType)) {
10738
+ hasExistingInitMethod = true;
10739
+ }
10740
+ }
10741
+ else {
10707
10742
  hasExistingInitMethod = true;
10708
10743
  }
10709
10744
  }
10710
- else {
10711
- hasExistingInitMethod = true;
10712
- }
10713
10745
  }
10714
10746
  }
10715
10747
  let skipSynthesizeHash = false;
10716
- const hashSymbol = (0, typeUtils_1.lookUpClassMember)(classType, '__hash__', 2 /* SkipBaseClasses */);
10748
+ const hashSymbol = (0, typeUtils_1.lookUpClassMember)(classType, '__hash__', 4 /* SkipObjectBaseClass */);
10717
10749
  if (hashSymbol) {
10718
- const hashSymbolType = getTypeOfMember(hashSymbol);
10719
- if ((0, types_1.isFunction)(hashSymbolType) && !types_1.FunctionType.isSynthesizedMethod(hashSymbolType)) {
10720
- skipSynthesizeHash = true;
10750
+ if (!(0, types_1.isClass)(hashSymbol.classType) || !types_1.ClassType.isBuiltIn(hashSymbol.classType, 'NamedTuple')) {
10751
+ const hashSymbolType = getTypeOfMember(hashSymbol);
10752
+ if ((0, types_1.isFunction)(hashSymbolType) && !types_1.FunctionType.isSynthesizedMethod(hashSymbolType)) {
10753
+ skipSynthesizeHash = true;
10754
+ }
10721
10755
  }
10722
10756
  }
10723
10757
  (0, dataClasses_1.synthesizeDataClassMethods)(evaluatorInterface, node, classType, skipSynthesizedInit, hasExistingInitMethod, skipSynthesizeHash);
@@ -14603,16 +14637,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
14603
14637
  // If the source is unbounded, expand the unbounded argument to try
14604
14638
  // to make the source and dest arg counts match.
14605
14639
  if (srcUnboundedIndex >= 0) {
14606
- const requiredSrcArgCount = destVariadicIndex >= 0 || destUnboundedIndex >= 0 ? destTypeArgs.length - 1 : destTypeArgs.length;
14607
14640
  const typeToReplicate = srcTypeArgs.length > 0 ? srcTypeArgs[srcUnboundedIndex].type : types_1.AnyType.create();
14608
- while (srcTypeArgs.length < requiredSrcArgCount) {
14609
- srcTypeArgs.splice(srcUnboundedIndex, 0, { type: typeToReplicate, isUnbounded: false });
14641
+ while (srcTypeArgs.length < destTypeArgs.length) {
14642
+ srcTypeArgs.splice(srcUnboundedIndex, 0, { type: typeToReplicate, isUnbounded: true });
14610
14643
  }
14611
14644
  }
14612
- if (destVariadicIndex >= 0 && srcUnboundedIndex >= 0) {
14613
- diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.typeVarTupleRequiresKnownLength());
14614
- return false;
14615
- }
14616
14645
  // If the dest is unbounded or contains a variadic, determine which
14617
14646
  // source args map to the unbounded or variadic arg.
14618
14647
  if (destUnboundedIndex >= 0 || destVariadicIndex >= 0) {
@@ -14625,7 +14654,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
14625
14654
  const removedArgs = srcTypeArgs.splice(destVariadicIndex, srcArgsToCapture);
14626
14655
  // Package up the remaining type arguments into a tuple object.
14627
14656
  const variadicTuple = (0, typeUtils_1.convertToInstance)((0, typeUtils_1.specializeTupleClass)(tupleClassType, removedArgs.map((typeArg) => {
14628
- return { type: stripLiteralValue(typeArg.type), isUnbounded: false };
14657
+ return { type: stripLiteralValue(typeArg.type), isUnbounded: typeArg.isUnbounded };
14629
14658
  }),
14630
14659
  /* isTypeArgumentExplicit */ true,
14631
14660
  /* isUnpackedTuple */ true));
@@ -14683,13 +14712,20 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
14683
14712
  // specified inheritance chain, taking into account its type arguments.
14684
14713
  function assignClassWithTypeArgs(destType, srcType, inheritanceChain, diag, destTypeVarContext, srcTypeVarContext, flags, recursionCount) {
14685
14714
  let curSrcType = srcType;
14686
- let curTypeVarContext = destTypeVarContext !== null && destTypeVarContext !== void 0 ? destTypeVarContext : new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(destType));
14715
+ let curTypeVarContext = destTypeVarContext;
14687
14716
  let effectiveFlags = flags;
14688
14717
  inferTypeParameterVarianceForClass(destType);
14689
- // If we're using a private typeVarContext, don't skip solving type vars.
14718
+ effectiveFlags |= 8 /* SkipSolveTypeVars */;
14690
14719
  if (!destTypeVarContext) {
14720
+ curTypeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(destType));
14691
14721
  effectiveFlags &= ~8 /* SkipSolveTypeVars */;
14692
14722
  }
14723
+ else {
14724
+ // If we're using the caller's type var context, don't solve the
14725
+ // type vars in this pass. We'll do this after we're done looping
14726
+ // through the inheritance chain.
14727
+ effectiveFlags |= 8 /* SkipSolveTypeVars */;
14728
+ }
14693
14729
  for (let ancestorIndex = inheritanceChain.length - 1; ancestorIndex >= 0; ancestorIndex--) {
14694
14730
  const ancestorType = inheritanceChain[ancestorIndex];
14695
14731
  // If we've hit an "unknown", all bets are off, and we need to assume
@@ -14857,22 +14893,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
14857
14893
  if ((0, types_1.isUnion)(srcType) && srcType.subtypes.length === 1 && (0, types_1.isVariadicTypeVar)(srcType.subtypes[0])) {
14858
14894
  srcType = srcType.subtypes[0];
14859
14895
  }
14860
- if (destType === srcType) {
14861
- // If the dest type is a TypeVar and a typeVarContext was provided, we may
14862
- // need to assign the TypeVar to itself under certain circumstances.
14863
- // This is needed for cases where generic class A[T] calls its own
14864
- // constructor with an argument of type T.
14865
- if ((0, types_1.isTypeVar)(destType) &&
14866
- !destType.details.isParamSpec &&
14867
- !destType.details.isVariadic &&
14868
- destType.scopeType === 0 /* Class */ &&
14869
- destTypeVarContext &&
14870
- !destTypeVarContext.isLocked() &&
14871
- destTypeVarContext.hasSolveForScope(destType.scopeId) &&
14872
- !destTypeVarContext.getTypeVar(destType) &&
14873
- (flags & (8 /* SkipSolveTypeVars */ | 2 /* ReverseTypeVarMatching */)) === 0) {
14874
- destTypeVarContext.setTypeVarType(destType, srcType);
14875
- }
14896
+ // Handle the case where the dest and src types are the same object.
14897
+ // We can normally shortcut this and say that they are compatible,
14898
+ // but if the type includes TypeVars, we need to go through
14899
+ // the rest of the logic.
14900
+ if (destType === srcType && !(0, typeUtils_1.requiresSpecialization)(destType)) {
14876
14901
  return true;
14877
14902
  }
14878
14903
  if (recursionCount > types_1.maxTypeRecursionCount) {
@@ -14928,13 +14953,26 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
14928
14953
  // Before performing any other checks, see if the dest type is a
14929
14954
  // TypeVar that we are attempting to match.
14930
14955
  if ((0, types_1.isTypeVar)(destType)) {
14956
+ if ((0, types_1.isTypeSame)(destType, srcType)) {
14957
+ if (destType.scopeId && (destTypeVarContext === null || destTypeVarContext === void 0 ? void 0 : destTypeVarContext.hasSolveForScope(destType.scopeId))) {
14958
+ return (0, constraintSolver_1.assignTypeToTypeVar)(evaluatorInterface, destType, srcType, diag, destTypeVarContext, flags, recursionCount);
14959
+ }
14960
+ return true;
14961
+ }
14931
14962
  // If the dest is a constrained or bound type variable and all of the
14932
14963
  // types in the source are conditioned on that same type variable
14933
14964
  // and have compatible types, we'll consider it assignable.
14934
14965
  if (assignConditionalTypeToTypeVar(destType, srcType, recursionCount)) {
14935
14966
  return true;
14936
14967
  }
14937
- if ((0, types_1.isTypeSame)(destType, srcType)) {
14968
+ // If the source is a conditional type associated with a bound TypeVar
14969
+ // and the bound TypeVar matches the condition, the types are compatible.
14970
+ const destTypeVar = destType;
14971
+ if (types_1.TypeBase.isInstantiable(destType) === types_1.TypeBase.isInstantiable(srcType) &&
14972
+ srcType.condition &&
14973
+ srcType.condition.some((cond) => {
14974
+ return !cond.isConstrainedTypeVar && cond.typeVarName === destTypeVar.nameWithScope;
14975
+ })) {
14938
14976
  return true;
14939
14977
  }
14940
14978
  if ((0, types_1.isUnion)(srcType)) {
@@ -15456,7 +15494,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15456
15494
  // For union sources, all of the types need to be assignable to the dest.
15457
15495
  let isIncompatible = false;
15458
15496
  // Sort the subtypes so we have a deterministic order for unions.
15459
- (0, typeUtils_1.doForEachSubtype)(srcType, (subtype, subtypeIndex) => {
15497
+ (0, typeUtils_1.doForEachSubtype)(srcType, (subtype, subtypeIndex, allSubtypes) => {
15460
15498
  if (isIncompatible) {
15461
15499
  return;
15462
15500
  }
@@ -15466,7 +15504,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15466
15504
  // Determine if the current subtype is subsumed by another subtype
15467
15505
  // in the same union. If so, we can ignore this.
15468
15506
  let isSubtypeSubsumed = false;
15469
- (0, typeUtils_1.doForEachSubtype)(srcType, (innerSubtype, innerSubtypeIndex) => {
15507
+ allSubtypes.forEach((innerSubtype, innerSubtypeIndex) => {
15470
15508
  if (isSubtypeSubsumed || subtypeIndex === innerSubtypeIndex || (0, types_1.isAnyOrUnknown)(innerSubtype)) {
15471
15509
  return;
15472
15510
  }
@@ -15807,7 +15845,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15807
15845
  let specializedDestType = destType;
15808
15846
  let reverseMatchingFailed = false;
15809
15847
  if ((flags & 2 /* ReverseTypeVarMatching */) === 0) {
15810
- specializedDestType = (0, typeUtils_1.applySolvedTypeVars)(destType, destTypeVarContext);
15848
+ specializedDestType = (0, typeUtils_1.applySolvedTypeVars)(destType, destTypeVarContext,
15849
+ /* unknownIfNotFound */ undefined,
15850
+ /* useNarrowBoundOnly */ true);
15811
15851
  if ((0, typeUtils_1.requiresSpecialization)(specializedDestType)) {
15812
15852
  reverseMatchingFailed = !assignType(specializedSrcType, specializedDestType,
15813
15853
  /* diag */ undefined, srcTypeVarContext, destTypeVarContext, (flags ^ 2 /* ReverseTypeVarMatching */) |
@@ -15817,7 +15857,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15817
15857
  }
15818
15858
  }
15819
15859
  else {
15820
- specializedSrcType = (0, typeUtils_1.applySolvedTypeVars)(srcType, srcTypeVarContext);
15860
+ specializedSrcType = (0, typeUtils_1.applySolvedTypeVars)(srcType, srcTypeVarContext,
15861
+ /* unknownIfNotFound */ undefined,
15862
+ /* useNarrowBoundOnly */ true);
15821
15863
  if ((0, typeUtils_1.requiresSpecialization)(specializedSrcType)) {
15822
15864
  reverseMatchingFailed = !assignType(specializedSrcType, specializedDestType,
15823
15865
  /* diag */ undefined, srcTypeVarContext, destTypeVarContext, (flags ^ 2 /* ReverseTypeVarMatching */) |