@zzzen/pyright-internal 1.2.0-dev.20230312 → 1.2.0-dev.20230319

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 (124) hide show
  1. package/dist/analyzer/backgroundAnalysisProgram.d.ts +1 -1
  2. package/dist/analyzer/backgroundAnalysisProgram.js +1 -1
  3. package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
  4. package/dist/analyzer/cacheManager.d.ts +4 -0
  5. package/dist/analyzer/cacheManager.js +13 -0
  6. package/dist/analyzer/cacheManager.js.map +1 -1
  7. package/dist/analyzer/checker.d.ts +2 -1
  8. package/dist/analyzer/checker.js +70 -26
  9. package/dist/analyzer/checker.js.map +1 -1
  10. package/dist/analyzer/codeFlowEngine.js +17 -11
  11. package/dist/analyzer/codeFlowEngine.js.map +1 -1
  12. package/dist/analyzer/program.d.ts +1 -1
  13. package/dist/analyzer/program.js +16 -15
  14. package/dist/analyzer/program.js.map +1 -1
  15. package/dist/analyzer/properties.js +0 -1
  16. package/dist/analyzer/properties.js.map +1 -1
  17. package/dist/analyzer/service.d.ts +2 -1
  18. package/dist/analyzer/service.js +9 -3
  19. package/dist/analyzer/service.js.map +1 -1
  20. package/dist/analyzer/sourceFile.d.ts +2 -2
  21. package/dist/analyzer/sourceFile.js +2 -2
  22. package/dist/analyzer/sourceFile.js.map +1 -1
  23. package/dist/analyzer/sourceFileInfoUtils.d.ts +1 -0
  24. package/dist/analyzer/sourceFileInfoUtils.js +17 -1
  25. package/dist/analyzer/sourceFileInfoUtils.js.map +1 -1
  26. package/dist/analyzer/typeEvaluator.js +48 -54
  27. package/dist/analyzer/typeEvaluator.js.map +1 -1
  28. package/dist/analyzer/typeEvaluatorTypes.d.ts +0 -2
  29. package/dist/analyzer/typeEvaluatorTypes.js +0 -3
  30. package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
  31. package/dist/analyzer/typeStubWriter.js +2 -0
  32. package/dist/analyzer/typeStubWriter.js.map +1 -1
  33. package/dist/analyzer/typeUtils.js +20 -0
  34. package/dist/analyzer/typeUtils.js.map +1 -1
  35. package/dist/analyzer/typedDicts.js +27 -0
  36. package/dist/analyzer/typedDicts.js.map +1 -1
  37. package/dist/analyzer/types.d.ts +4 -1
  38. package/dist/analyzer/types.js +3 -1
  39. package/dist/analyzer/types.js.map +1 -1
  40. package/dist/commands/dumpFileDebugInfoCommand.js +4 -4
  41. package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
  42. package/dist/commands/quickActionCommand.js +2 -2
  43. package/dist/commands/quickActionCommand.js.map +1 -1
  44. package/dist/common/configOptions.d.ts +1 -0
  45. package/dist/common/configOptions.js +4 -0
  46. package/dist/common/configOptions.js.map +1 -1
  47. package/dist/common/console.d.ts +1 -0
  48. package/dist/common/console.js +19 -1
  49. package/dist/common/console.js.map +1 -1
  50. package/dist/common/diagnosticRules.d.ts +2 -1
  51. package/dist/common/diagnosticRules.js +1 -0
  52. package/dist/common/diagnosticRules.js.map +1 -1
  53. package/dist/common/extensibility.d.ts +2 -2
  54. package/dist/common/extensibility.js.map +1 -1
  55. package/dist/common/extensions.js +3 -1
  56. package/dist/common/extensions.js.map +1 -1
  57. package/dist/languageServerBase.d.ts +21 -46
  58. package/dist/languageServerBase.js +109 -151
  59. package/dist/languageServerBase.js.map +1 -1
  60. package/dist/languageService/analyzerServiceExecutor.d.ts +4 -3
  61. package/dist/languageService/analyzerServiceExecutor.js +9 -7
  62. package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
  63. package/dist/languageService/codeActionProvider.d.ts +2 -2
  64. package/dist/languageService/codeActionProvider.js +4 -4
  65. package/dist/languageService/codeActionProvider.js.map +1 -1
  66. package/dist/languageService/completionProvider.js +3 -5
  67. package/dist/languageService/completionProvider.js.map +1 -1
  68. package/dist/languageService/definitionProvider.js +1 -1
  69. package/dist/languageService/definitionProvider.js.map +1 -1
  70. package/dist/languageService/documentSymbolCollector.d.ts +2 -1
  71. package/dist/languageService/documentSymbolCollector.js +23 -2
  72. package/dist/languageService/documentSymbolCollector.js.map +1 -1
  73. package/dist/languageService/hoverProvider.d.ts +2 -1
  74. package/dist/languageService/hoverProvider.js +21 -5
  75. package/dist/languageService/hoverProvider.js.map +1 -1
  76. package/dist/languageService/referencesProvider.d.ts +3 -2
  77. package/dist/languageService/referencesProvider.js +4 -4
  78. package/dist/languageService/referencesProvider.js.map +1 -1
  79. package/dist/localization/localize.d.ts +14 -6
  80. package/dist/localization/localize.js +5 -4
  81. package/dist/localization/localize.js.map +1 -1
  82. package/dist/localization/package.nls.en-us.json +7 -6
  83. package/dist/parser/parser.js +4 -2
  84. package/dist/parser/parser.js.map +1 -1
  85. package/dist/server.d.ts +3 -2
  86. package/dist/server.js +1 -4
  87. package/dist/server.js.map +1 -1
  88. package/dist/tests/cacheManager.test.d.ts +1 -0
  89. package/dist/tests/cacheManager.test.js +69 -0
  90. package/dist/tests/cacheManager.test.js.map +1 -0
  91. package/dist/tests/checker.test.js +2 -2
  92. package/dist/tests/completions.test.js +2 -2
  93. package/dist/tests/completions.test.js.map +1 -1
  94. package/dist/tests/fourslash/missingTypeStub.command.trycatchImport.fourslash.d.ts +7 -0
  95. package/dist/tests/fourslash/missingTypeStub.command.trycatchImport.fourslash.js +45 -0
  96. package/dist/tests/fourslash/missingTypeStub.command.trycatchImport.fourslash.js.map +1 -0
  97. package/dist/tests/harness/fourslash/testLanguageService.d.ts +7 -6
  98. package/dist/tests/harness/fourslash/testLanguageService.js +14 -13
  99. package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
  100. package/dist/tests/harness/fourslash/testState.d.ts +5 -4
  101. package/dist/tests/harness/fourslash/testState.js +14 -13
  102. package/dist/tests/harness/fourslash/testState.js.map +1 -1
  103. package/dist/tests/moveSymbol.misc.test.js +1 -1
  104. package/dist/tests/moveSymbol.misc.test.js.map +1 -1
  105. package/dist/tests/service.test.js +4 -4
  106. package/dist/tests/service.test.js.map +1 -1
  107. package/dist/tests/signatureHelp.test.js +2 -2
  108. package/dist/tests/signatureHelp.test.js.map +1 -1
  109. package/dist/tests/sourceFile.test.js +3 -3
  110. package/dist/tests/sourceFile.test.js.map +1 -1
  111. package/dist/tests/typeEvaluator2.test.js +2 -2
  112. package/dist/tests/typeEvaluator3.test.js +1 -1
  113. package/dist/tests/typeEvaluator4.test.js +1 -1
  114. package/dist/tests/typeEvaluator5.test.js +12 -0
  115. package/dist/tests/typeEvaluator5.test.js.map +1 -1
  116. package/dist/tests/workspaceEditUtils.test.js +2 -2
  117. package/dist/tests/workspaceEditUtils.test.js.map +1 -1
  118. package/dist/workspaceFactory.d.ts +72 -0
  119. package/dist/workspaceFactory.js +421 -0
  120. package/dist/workspaceFactory.js.map +1 -0
  121. package/package.json +4 -4
  122. package/dist/workspaceMap.d.ts +0 -14
  123. package/dist/workspaceMap.js +0 -172
  124. package/dist/workspaceMap.js.map +0 -1
@@ -705,11 +705,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
705
705
  }
706
706
  }
707
707
  }
708
- if (flags & 65536 /* DisallowRecursiveTypeAliasPlaceholder */) {
709
- if ((0, types_1.isTypeVar)(typeResult.type) && (0, typeUtils_1.isTypeAliasPlaceholder)(typeResult.type)) {
710
- typeResult.type.details.illegalRecursionDetected = true;
711
- }
712
- }
713
708
  writeTypeCache(node, typeResult, flags, inferenceContext, /* allowSpeculativeCaching */ true);
714
709
  if (inferenceContext &&
715
710
  !(0, types_1.isAnyOrUnknown)(inferenceContext.expectedType) &&
@@ -946,7 +941,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
946
941
  return getTypeOfAnnotation(paramTypeNode, {
947
942
  associateTypeVarsWithScope: true,
948
943
  allowTypeVarTuple: paramCategory === 1 /* VarArgList */,
949
- disallowRecursiveTypeAlias: true,
950
944
  allowUnpackedTypedDict: paramCategory === 2 /* VarArgDictionary */,
951
945
  allowUnpackedTuple: paramCategory === 1 /* VarArgList */,
952
946
  });
@@ -990,9 +984,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
990
984
  else {
991
985
  evaluatorFlags |= 4096 /* DisallowTypeVarsWithoutScopeId */;
992
986
  }
993
- if (options === null || options === void 0 ? void 0 : options.disallowRecursiveTypeAlias) {
994
- evaluatorFlags |= 65536 /* DisallowRecursiveTypeAliasPlaceholder */;
995
- }
996
987
  if (options === null || options === void 0 ? void 0 : options.allowUnpackedTypedDict) {
997
988
  evaluatorFlags |= 8388608 /* AllowUnpackedTypedDict */;
998
989
  }
@@ -4548,10 +4539,17 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
4548
4539
  // See if the class has a custom metaclass that supports __getitem__, etc.
4549
4540
  if (concreteSubtype.details.effectiveMetaclass &&
4550
4541
  (0, types_1.isInstantiableClass)(concreteSubtype.details.effectiveMetaclass) &&
4551
- !types_1.ClassType.isBuiltIn(concreteSubtype.details.effectiveMetaclass, ['type', '_InitVarMeta'])) {
4542
+ !types_1.ClassType.isBuiltIn(concreteSubtype.details.effectiveMetaclass, ['type', '_InitVarMeta']) &&
4543
+ (flags & 128 /* ExpectingType */) === 0) {
4552
4544
  const itemMethodType = getTypeOfClassMember(node, concreteSubtype, getIndexAccessMagicMethodName(usage),
4553
4545
  /* usage */ undefined,
4554
4546
  /* diag */ undefined, 64 /* SkipAttributeAccessOverride */ | 32 /* ConsiderMetaclassOnly */);
4547
+ if (flags & 256 /* ExpectingTypeAnnotation */) {
4548
+ // If the class doesn't derive from Generic, a type argument should not be allowed.
4549
+ addDiagnostic(AnalyzerNodeInfo.getFileInfo(node).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.typeArgsExpectingNone().format({
4550
+ name: printType(types_1.ClassType.cloneAsInstance(concreteSubtype)),
4551
+ }), node);
4552
+ }
4555
4553
  if (itemMethodType) {
4556
4554
  return getTypeOfIndexedObjectOrClass(node, concreteSubtype, usage).type;
4557
4555
  }
@@ -4967,7 +4965,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
4967
4965
  adjFlags &= ~(2 /* DoNotSpecialize */ |
4968
4966
  32 /* DisallowParamSpec */ |
4969
4967
  64 /* DisallowTypeVarTuple */ |
4970
- 1048576 /* AllowRequired */);
4968
+ 1048576 /* AllowRequired */ |
4969
+ 16384 /* EnforceTypeVarVarianceConsistency */);
4971
4970
  if (!(options === null || options === void 0 ? void 0 : options.isAnnotatedClass)) {
4972
4971
  adjFlags |= 131072 /* DisallowClassVar */ | 16 /* DisallowFinal */;
4973
4972
  }
@@ -6548,7 +6547,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
6548
6547
  return returnType;
6549
6548
  }
6550
6549
  else {
6551
- const memberType = (_d = getTypeOfObjectMember(errorNode, expandedSubtype, '__call__')) === null || _d === void 0 ? void 0 : _d.type;
6550
+ const memberType = (_d = getTypeOfObjectMember(errorNode, expandedSubtype, '__call__',
6551
+ /* usage */ undefined,
6552
+ /* diag */ undefined, 64 /* SkipAttributeAccessOverride */)) === null || _d === void 0 ? void 0 : _d.type;
6552
6553
  if (memberType) {
6553
6554
  const functionResult = validateCallArguments(errorNode, argList, { type: memberType }, typeVarContext, skipUnknownArgCheck, inferenceContext, recursionCount);
6554
6555
  overloadsUsedForCall.push(...functionResult.overloadsUsedForCall);
@@ -10486,7 +10487,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
10486
10487
  !ParseTreeUtils.isNodeContainedWithin(errorNode, firstParamTypeAnnotation)) {
10487
10488
  const annotationType = getTypeOfAnnotation(firstParamTypeAnnotation, {
10488
10489
  associateTypeVarsWithScope: true,
10489
- disallowRecursiveTypeAlias: true,
10490
10490
  });
10491
10491
  if (!(0, types_1.isTypeVar)(annotationType) || !annotationType.details.isSynthesizedSelf) {
10492
10492
  addDiagnostic(fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.selfTypeWithTypedSelfOrCls(), errorNode);
@@ -11145,11 +11145,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11145
11145
  // can be specialized.
11146
11146
  typeAliasTypeVar.details.recursiveTypeParameters = (_a = rightHandType.typeAliasInfo) === null || _a === void 0 ? void 0 : _a.typeParameters;
11147
11147
  }
11148
- if (typeAliasTypeVar.details.illegalRecursionDetected) {
11149
- addDiagnostic(fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.typeAliasIsRecursiveIndirect().format({
11150
- name: typeAliasNameNode.value,
11151
- }), node.leftExpression);
11152
- }
11153
11148
  }
11154
11149
  }
11155
11150
  }
@@ -11235,11 +11230,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11235
11230
  // Set the resulting type to the boundType of the original type alias
11236
11231
  // to support recursive type aliases.
11237
11232
  typeAliasTypeVar.details.boundType = aliasType;
11238
- if (typeAliasTypeVar.details.illegalRecursionDetected) {
11239
- addDiagnostic(AnalyzerNodeInfo.getFileInfo(node).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.typeAliasIsRecursiveIndirect().format({
11240
- name: node.name.value,
11241
- }), node.name);
11242
- }
11243
11233
  writeTypeCache(node.name, { type: aliasType, isIncomplete }, 0 /* None */);
11244
11234
  return aliasType;
11245
11235
  }
@@ -12437,7 +12427,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
12437
12427
  functionType.details.declaredReturnType = types_1.UnknownType.create();
12438
12428
  const returnType = getTypeOfAnnotation(returnTypeAnnotationNode, {
12439
12429
  associateTypeVarsWithScope: true,
12440
- disallowRecursiveTypeAlias: true,
12441
12430
  });
12442
12431
  functionType.details.declaredReturnType = returnType;
12443
12432
  }
@@ -13609,7 +13598,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
13609
13598
  annotationNode === annotationParent.returnTypeAnnotation) {
13610
13599
  getTypeOfAnnotation(annotationNode, {
13611
13600
  associateTypeVarsWithScope: true,
13612
- disallowRecursiveTypeAlias: true,
13613
13601
  });
13614
13602
  return;
13615
13603
  }
@@ -15085,15 +15073,19 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15085
15073
  if (((_a = resolvedDecl.inferredTypeSource) === null || _a === void 0 ? void 0 : _a.nodeType) === 9 /* Call */) {
15086
15074
  const baseTypeResult = getTypeOfExpression(resolvedDecl.inferredTypeSource.leftExpression, 2 /* DoNotSpecialize */);
15087
15075
  const callType = baseTypeResult.type;
15088
- if ((0, types_1.isInstantiableClass)(callType) &&
15089
- types_1.ClassType.isBuiltIn(callType, [
15090
- 'TypeVar',
15091
- 'ParamSpec',
15092
- 'TypeVarTuple',
15093
- 'TypedDict',
15094
- 'NamedTuple',
15095
- 'NewType',
15096
- ])) {
15076
+ const exemptBuiltins = [
15077
+ 'TypeVar',
15078
+ 'ParamSpec',
15079
+ 'TypeVarTuple',
15080
+ 'TypedDict',
15081
+ 'NamedTuple',
15082
+ 'NewType',
15083
+ ];
15084
+ if ((0, types_1.isInstantiableClass)(callType) && types_1.ClassType.isBuiltIn(callType, exemptBuiltins)) {
15085
+ isUnambiguousType = true;
15086
+ }
15087
+ else if ((0, types_1.isFunction)(callType) &&
15088
+ exemptBuiltins.some((name) => callType.details.builtInName === name)) {
15097
15089
  isUnambiguousType = true;
15098
15090
  }
15099
15091
  }
@@ -16783,6 +16775,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16783
16775
  if ((0, types_1.isTypeSame)(srcType, destType, {}, recursionCount)) {
16784
16776
  return true;
16785
16777
  }
16778
+ // Sort the subtypes so we have a deterministic order for unions.
16779
+ let sortedSrcTypes = (0, typeUtils_1.sortTypes)(srcType.subtypes);
16786
16780
  // Handle the case where the source and dest are both unions. Try
16787
16781
  // to eliminate as many exact type matches between the src and dest.
16788
16782
  if ((0, types_1.isUnion)(destType)) {
@@ -16797,8 +16791,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16797
16791
  return true;
16798
16792
  }
16799
16793
  const remainingDestSubtypes = [];
16800
- let remainingSrcSubtypes = [...srcType.subtypes];
16801
- let isIncompatible = false;
16794
+ let remainingSrcSubtypes = sortedSrcTypes;
16795
+ let canUseFastPath = true;
16802
16796
  // First attempt to match all of the non-generic types in the dest
16803
16797
  // to non-generic types in the source.
16804
16798
  destType.subtypes.forEach((destSubtype) => {
@@ -16817,7 +16811,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16817
16811
  });
16818
16812
  // For all remaining source subtypes, attempt to find a dest subtype
16819
16813
  // whose primary type matches.
16820
- (0, typeUtils_1.sortTypes)(remainingSrcSubtypes).forEach((srcSubtype) => {
16814
+ remainingSrcSubtypes.forEach((srcSubtype) => {
16821
16815
  const destTypeIndex = remainingDestSubtypes.findIndex((destSubtype) => {
16822
16816
  if ((0, types_1.isClass)(srcSubtype) &&
16823
16817
  (0, types_1.isClass)(destSubtype) &&
@@ -16834,7 +16828,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16834
16828
  });
16835
16829
  if (destTypeIndex >= 0) {
16836
16830
  if (!assignType(remainingDestSubtypes[destTypeIndex], srcSubtype, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), destTypeVarContext, srcTypeVarContext, flags, recursionCount)) {
16837
- isIncompatible = true;
16831
+ canUseFastPath = false;
16838
16832
  }
16839
16833
  remainingDestSubtypes.splice(destTypeIndex, 1);
16840
16834
  remainingSrcSubtypes = remainingSrcSubtypes.filter((t) => t !== srcSubtype);
@@ -16842,11 +16836,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16842
16836
  });
16843
16837
  // If there is are remaining dest subtypes and they're all type variables,
16844
16838
  // attempt to assign the remaining source subtypes to them.
16845
- if (!isIncompatible && (remainingDestSubtypes.length !== 0 || remainingSrcSubtypes.length !== 0)) {
16839
+ if (canUseFastPath && (remainingDestSubtypes.length !== 0 || remainingSrcSubtypes.length !== 0)) {
16846
16840
  const isReversed = (flags & 2 /* ReverseTypeVarMatching */) !== 0;
16847
16841
  const effectiveDestSubtypes = isReversed ? remainingSrcSubtypes : remainingDestSubtypes;
16848
16842
  if (effectiveDestSubtypes.length === 0 || effectiveDestSubtypes.some((t) => !(0, types_1.isTypeVar)(t))) {
16849
- isIncompatible = true;
16843
+ canUseFastPath = false;
16844
+ // We can avoid checking the source subtypes that have already been checked.
16845
+ sortedSrcTypes = remainingSrcSubtypes;
16850
16846
  }
16851
16847
  else if (remainingDestSubtypes.length === remainingSrcSubtypes.length) {
16852
16848
  // If the number of remaining source subtypes is the same as the number
@@ -16854,9 +16850,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16854
16850
  remainingDestSubtypes.forEach((destSubtype, index) => {
16855
16851
  const srcSubtype = remainingSrcSubtypes[index];
16856
16852
  if (!assignType(destSubtype, srcSubtype, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), destTypeVarContext, srcTypeVarContext, flags, recursionCount)) {
16857
- isIncompatible = true;
16853
+ canUseFastPath = false;
16858
16854
  }
16859
16855
  });
16856
+ // We can avoid checking the source subtypes that have already been checked.
16857
+ sortedSrcTypes = remainingSrcSubtypes;
16860
16858
  }
16861
16859
  else if (remainingSrcSubtypes.length === 0) {
16862
16860
  if ((flags & 1024 /* PopulatingExpectedType */) !== 0) {
@@ -16870,24 +16868,21 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16870
16868
  }
16871
16869
  // If we've assigned all of the source subtypes but one or more dest
16872
16870
  // TypeVars have gone unmatched, treat this as success.
16873
- return true;
16874
16871
  }
16875
16872
  else {
16876
16873
  // Try to assign a union of the remaining source types to
16877
16874
  // the first destination TypeVar.
16878
16875
  if (!assignType(isReversed ? (0, types_1.combineTypes)(remainingDestSubtypes) : remainingDestSubtypes[0], isReversed ? remainingSrcSubtypes[0] : (0, types_1.combineTypes)(remainingSrcSubtypes), diag === null || diag === void 0 ? void 0 : diag.createAddendum(), destTypeVarContext, srcTypeVarContext, flags, recursionCount)) {
16879
- isIncompatible = true;
16876
+ canUseFastPath = false;
16880
16877
  }
16881
16878
  }
16882
16879
  }
16883
- if (!isIncompatible) {
16880
+ if (canUseFastPath) {
16884
16881
  return true;
16885
16882
  }
16886
16883
  }
16887
- // For union sources, all of the types need to be assignable to the dest.
16888
16884
  let isIncompatible = false;
16889
- // Sort the subtypes so we have a deterministic order for unions.
16890
- (0, typeUtils_1.doForEachSubtype)(srcType, (subtype, subtypeIndex, allSubtypes) => {
16885
+ sortedSrcTypes.forEach((subtype) => {
16891
16886
  if (isIncompatible) {
16892
16887
  return;
16893
16888
  }
@@ -16897,11 +16892,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16897
16892
  // Determine if the current subtype is subsumed by another subtype
16898
16893
  // in the same union. If so, we can ignore this.
16899
16894
  let isSubtypeSubsumed = false;
16900
- allSubtypes.forEach((innerSubtype, innerSubtypeIndex) => {
16901
- if (isSubtypeSubsumed || subtypeIndex === innerSubtypeIndex || (0, types_1.isAnyOrUnknown)(innerSubtype)) {
16902
- return;
16903
- }
16904
- if (isProperSubtype(innerSubtype, concreteSubtype, recursionCount)) {
16895
+ srcType.subtypes.forEach((innerSubtype) => {
16896
+ if (!isSubtypeSubsumed &&
16897
+ !(0, types_1.isTypeSame)(innerSubtype, subtype) &&
16898
+ !(0, types_1.isAnyOrUnknown)(innerSubtype) &&
16899
+ isProperSubtype(innerSubtype, concreteSubtype, recursionCount)) {
16905
16900
  isSubtypeSubsumed = true;
16906
16901
  }
16907
16902
  });
@@ -16911,8 +16906,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16911
16906
  isIncompatible = true;
16912
16907
  }
16913
16908
  }
16914
- },
16915
- /* sortSubtypes */ true);
16909
+ }, /* sortSubtypes */ true);
16916
16910
  if (isIncompatible) {
16917
16911
  diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.typeAssignmentMismatch().format({
16918
16912
  sourceType: printType(srcType),