@zzzen/pyright-internal 1.2.0-dev.20240922 → 1.2.0-dev.20240929

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 (102) hide show
  1. package/dist/analyzer/binder.d.ts +1 -0
  2. package/dist/analyzer/binder.js +19 -0
  3. package/dist/analyzer/binder.js.map +1 -1
  4. package/dist/analyzer/checker.d.ts +0 -1
  5. package/dist/analyzer/checker.js +68 -82
  6. package/dist/analyzer/checker.js.map +1 -1
  7. package/dist/analyzer/commentUtils.js +2 -2
  8. package/dist/analyzer/commentUtils.js.map +1 -1
  9. package/dist/analyzer/constraintSolver.js +3 -3
  10. package/dist/analyzer/constraintSolver.js.map +1 -1
  11. package/dist/analyzer/constructors.js +14 -6
  12. package/dist/analyzer/constructors.js.map +1 -1
  13. package/dist/analyzer/importResolver.js +1 -1
  14. package/dist/analyzer/importResolver.js.map +1 -1
  15. package/dist/analyzer/operations.js +42 -28
  16. package/dist/analyzer/operations.js.map +1 -1
  17. package/dist/analyzer/packageTypeVerifier.js +4 -4
  18. package/dist/analyzer/packageTypeVerifier.js.map +1 -1
  19. package/dist/analyzer/patternMatching.js +7 -4
  20. package/dist/analyzer/patternMatching.js.map +1 -1
  21. package/dist/analyzer/service.js +24 -10
  22. package/dist/analyzer/service.js.map +1 -1
  23. package/dist/analyzer/sourceMapper.js +5 -3
  24. package/dist/analyzer/sourceMapper.js.map +1 -1
  25. package/dist/analyzer/symbol.d.ts +3 -0
  26. package/dist/analyzer/symbol.js +6 -0
  27. package/dist/analyzer/symbol.js.map +1 -1
  28. package/dist/analyzer/tracePrinter.js +5 -5
  29. package/dist/analyzer/tracePrinter.js.map +1 -1
  30. package/dist/analyzer/typeEvaluator.js +147 -100
  31. package/dist/analyzer/typeEvaluator.js.map +1 -1
  32. package/dist/analyzer/typeGuards.js +7 -1
  33. package/dist/analyzer/typeGuards.js.map +1 -1
  34. package/dist/analyzer/typePrinter.js +16 -12
  35. package/dist/analyzer/typePrinter.js.map +1 -1
  36. package/dist/analyzer/typeUtils.d.ts +1 -0
  37. package/dist/analyzer/typeUtils.js +16 -4
  38. package/dist/analyzer/typeUtils.js.map +1 -1
  39. package/dist/analyzer/types.d.ts +7 -3
  40. package/dist/analyzer/types.js +6 -0
  41. package/dist/analyzer/types.js.map +1 -1
  42. package/dist/common/configOptions.d.ts +3 -1
  43. package/dist/common/configOptions.js +17 -4
  44. package/dist/common/configOptions.js.map +1 -1
  45. package/dist/common/fileSystem.d.ts +8 -1
  46. package/dist/common/fileSystem.js +10 -1
  47. package/dist/common/fileSystem.js.map +1 -1
  48. package/dist/common/memUtils.js +3 -0
  49. package/dist/common/memUtils.js.map +1 -1
  50. package/dist/common/pathUtils.d.ts +3 -3
  51. package/dist/common/realFileSystem.js +2 -0
  52. package/dist/common/realFileSystem.js.map +1 -1
  53. package/dist/languageService/autoImporter.d.ts +9 -7
  54. package/dist/languageService/autoImporter.js +32 -34
  55. package/dist/languageService/autoImporter.js.map +1 -1
  56. package/dist/languageService/completionProvider.js +1 -1
  57. package/dist/languageService/completionProvider.js.map +1 -1
  58. package/dist/languageService/completionProviderUtils.js +1 -1
  59. package/dist/languageService/completionProviderUtils.js.map +1 -1
  60. package/dist/languageService/hoverProvider.js +3 -2
  61. package/dist/languageService/hoverProvider.js.map +1 -1
  62. package/dist/languageService/symbolIndexer.d.ts +8 -1
  63. package/dist/languageService/symbolIndexer.js +17 -2
  64. package/dist/languageService/symbolIndexer.js.map +1 -1
  65. package/dist/localization/localize.d.ts +1 -0
  66. package/dist/localization/localize.js +1 -0
  67. package/dist/localization/localize.js.map +1 -1
  68. package/dist/localization/package.nls.cs.json +2 -2
  69. package/dist/localization/package.nls.de.json +2 -2
  70. package/dist/localization/package.nls.en-us.json +4 -0
  71. package/dist/localization/package.nls.es.json +2 -2
  72. package/dist/localization/package.nls.fr.json +2 -2
  73. package/dist/localization/package.nls.it.json +2 -2
  74. package/dist/localization/package.nls.ja.json +2 -2
  75. package/dist/localization/package.nls.ko.json +2 -2
  76. package/dist/localization/package.nls.pl.json +2 -2
  77. package/dist/localization/package.nls.pt-br.json +2 -2
  78. package/dist/localization/package.nls.ru.json +2 -2
  79. package/dist/localization/package.nls.tr.json +2 -2
  80. package/dist/localization/package.nls.zh-cn.json +2 -2
  81. package/dist/localization/package.nls.zh-tw.json +2 -2
  82. package/dist/readonlyAugmentedFileSystem.js +2 -1
  83. package/dist/readonlyAugmentedFileSystem.js.map +1 -1
  84. package/dist/tests/harness/fourslash/testLanguageService.d.ts +0 -1
  85. package/dist/tests/harness/fourslash/testLanguageService.js +0 -3
  86. package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
  87. package/dist/tests/harness/fourslash/testState.d.ts +1 -2
  88. package/dist/tests/harness/fourslash/testState.js +0 -7
  89. package/dist/tests/harness/fourslash/testState.js.map +1 -1
  90. package/dist/tests/harness/vfs/filesystem.js +8 -3
  91. package/dist/tests/harness/vfs/filesystem.js.map +1 -1
  92. package/dist/tests/sourceMapperUtils.test.js +2 -2
  93. package/dist/tests/sourceMapperUtils.test.js.map +1 -1
  94. package/dist/tests/typeEvaluator3.test.js +6 -0
  95. package/dist/tests/typeEvaluator3.test.js.map +1 -1
  96. package/dist/tests/typeEvaluator4.test.js +4 -0
  97. package/dist/tests/typeEvaluator4.test.js.map +1 -1
  98. package/dist/tests/typeEvaluator6.test.js +6 -2
  99. package/dist/tests/typeEvaluator6.test.js.map +1 -1
  100. package/dist/tests/typeEvaluator8.test.js +7 -1
  101. package/dist/tests/typeEvaluator8.test.js.map +1 -1
  102. package/package.json +8 -8
@@ -391,7 +391,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
391
391
  // context, logging any errors in the process. This may require the
392
392
  // type of surrounding statements to be evaluated.
393
393
  function getType(node) {
394
- var _a, _b;
394
+ var _a, _b, _c, _d;
395
395
  initializePrefetchedTypes(node);
396
396
  let type = (_a = evaluateTypeForSubnode(node, () => {
397
397
  evaluateTypesForExpressionInContext(node);
@@ -406,8 +406,20 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
406
406
  if (classTypeResult) {
407
407
  inferVarianceForClass(classTypeResult.classType);
408
408
  const typeParam = classTypeResult.classType.shared.typeParams.find((param) => (0, types_1.isTypeSame)(param, typeVarType, { ignoreTypeFlags: true }));
409
- if (typeParam) {
410
- type = types_1.TypeBase.isInstance(type) ? types_1.TypeVarType.cloneAsInstance(typeParam) : typeParam;
409
+ if ((typeParam === null || typeParam === void 0 ? void 0 : typeParam.priv.computedVariance) !== undefined) {
410
+ type = types_1.TypeVarType.cloneWithComputedVariance(type, typeParam.priv.computedVariance);
411
+ }
412
+ }
413
+ }
414
+ else if (((_c = typeParamListNode === null || typeParamListNode === void 0 ? void 0 : typeParamListNode.parent) === null || _c === void 0 ? void 0 : _c.nodeType) === 77 /* ParseNodeType.TypeAlias */) {
415
+ const typeAliasType = getTypeOfTypeAlias(typeParamListNode.parent);
416
+ const typeParamIndex = typeParamListNode.d.params.findIndex((param) => param.d.name === node);
417
+ if (typeParamIndex >= 0) {
418
+ inferVarianceForTypeAlias(typeAliasType);
419
+ const typeAliasInfo = (_d = typeAliasType.props) === null || _d === void 0 ? void 0 : _d.typeAliasInfo;
420
+ if (typeAliasInfo === null || typeAliasInfo === void 0 ? void 0 : typeAliasInfo.shared.computedVariance) {
421
+ const computedVariance = typeAliasInfo.shared.computedVariance[typeParamIndex];
422
+ type = types_1.TypeVarType.cloneWithComputedVariance(type, computedVariance);
411
423
  }
412
424
  }
413
425
  }
@@ -994,7 +1006,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
994
1006
  updatedFlags |= 524288 /* EvalFlags.NotParsed */;
995
1007
  }
996
1008
  updatedFlags &= ~1073741824 /* EvalFlags.TypeFormArg */;
997
- if (node.d.annotation) {
1009
+ if (node.d.annotation && (flags & 256 /* EvalFlags.TypeExpression */) !== 0) {
998
1010
  return getTypeOfExpression(node.d.annotation, updatedFlags);
999
1011
  }
1000
1012
  if (node.d.strings.length === 1) {
@@ -3259,7 +3271,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
3259
3271
  // Isinstance treats traditional (non-PEP 695) type aliases that are unions
3260
3272
  // as tuples of classes rather than unions.
3261
3273
  if ((flags & 536870912 /* EvalFlags.IsinstanceArg */) !== 0) {
3262
- if ((0, types_1.isUnion)(type) && ((_a = type.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo) && !type.props.typeAliasInfo.isPep695Syntax) {
3274
+ if ((0, types_1.isUnion)(type) && ((_a = type.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo) && !type.props.typeAliasInfo.shared.isPep695Syntax) {
3263
3275
  return type;
3264
3276
  }
3265
3277
  }
@@ -3607,7 +3619,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
3607
3619
  }
3608
3620
  }
3609
3621
  return {
3610
- type: types_1.TypeVarType.cloneForScopeId(type, leftType.shared.recursiveAlias.scopeId, leftType.shared.recursiveAlias.name, 2 /* TypeVarScopeType.TypeAlias */),
3622
+ type: types_1.TypeVarType.cloneForScopeId(type, leftType.shared.recursiveAlias.typeVarScopeId, leftType.shared.recursiveAlias.name, 2 /* TypeVarScopeType.TypeAlias */),
3611
3623
  scopeNode,
3612
3624
  foundInterveningClass: false,
3613
3625
  };
@@ -4821,13 +4833,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
4821
4833
  return type;
4822
4834
  }
4823
4835
  // Is this a generic type alias that needs specializing?
4824
- if (!aliasInfo.typeParams || aliasInfo.typeParams.length === 0 || aliasInfo.typeArgs) {
4836
+ if (!aliasInfo.shared.typeParams || aliasInfo.shared.typeParams.length === 0 || aliasInfo.typeArgs) {
4825
4837
  return type;
4826
4838
  }
4827
4839
  let reportDiag = false;
4828
4840
  const defaultTypeArgs = [];
4829
4841
  const constraints = new constraintTracker_1.ConstraintTracker();
4830
- aliasInfo.typeParams.forEach((param) => {
4842
+ aliasInfo.shared.typeParams.forEach((param) => {
4831
4843
  if (!param.shared.isDefaultExplicit) {
4832
4844
  reportDiag = true;
4833
4845
  }
@@ -4835,7 +4847,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
4835
4847
  if (param.shared.isDefaultExplicit || (0, types_1.isParamSpec)(param)) {
4836
4848
  defaultType = solveAndApplyConstraints(param, constraints, {
4837
4849
  replaceUnsolved: {
4838
- scopeIds: [aliasInfo.typeVarScopeId],
4850
+ scopeIds: [aliasInfo.shared.typeVarScopeId],
4839
4851
  tupleClassType: getTupleClassType(),
4840
4852
  },
4841
4853
  });
@@ -4852,12 +4864,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
4852
4864
  });
4853
4865
  if (reportDiag && errorNode) {
4854
4866
  addDiagnostic(diagnosticRules_1.DiagnosticRule.reportMissingTypeArgument, localize_1.LocMessage.typeArgsMissingForAlias().format({
4855
- name: aliasInfo.name,
4867
+ name: aliasInfo.shared.name,
4856
4868
  }), errorNode);
4857
4869
  }
4858
4870
  type = types_1.TypeBase.cloneForTypeAlias(solveAndApplyConstraints(type, constraints, {
4859
4871
  replaceUnsolved: {
4860
- scopeIds: [aliasInfo.typeVarScopeId],
4872
+ scopeIds: [aliasInfo.shared.typeVarScopeId],
4861
4873
  tupleClassType: getTupleClassType(),
4862
4874
  },
4863
4875
  }), { ...aliasInfo, typeArgs: defaultTypeArgs });
@@ -4873,7 +4885,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
4873
4885
  aliasInfo = (_d = (_c = baseType.props.typeForm) === null || _c === void 0 ? void 0 : _c.props) === null || _d === void 0 ? void 0 : _d.typeAliasInfo;
4874
4886
  aliasBaseType = (0, typeUtils_1.convertToInstantiable)(baseType.props.typeForm);
4875
4887
  }
4876
- if (!(aliasInfo === null || aliasInfo === void 0 ? void 0 : aliasInfo.typeParams) || (aliasInfo.typeParams.length === 0 && aliasInfo.typeArgs)) {
4888
+ if (!(aliasInfo === null || aliasInfo === void 0 ? void 0 : aliasInfo.shared.typeParams) || (aliasInfo.shared.typeParams.length === 0 && aliasInfo.typeArgs)) {
4877
4889
  return undefined;
4878
4890
  }
4879
4891
  // If this is not instantiable, then the index expression isn't a specialization.
@@ -4884,7 +4896,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
4884
4896
  if (aliasInfo.typeArgs) {
4885
4897
  return undefined;
4886
4898
  }
4887
- const typeParams = aliasInfo.typeParams;
4899
+ inferVarianceForTypeAlias(baseType);
4900
+ const typeParams = aliasInfo.shared.typeParams;
4888
4901
  let typeArgs = adjustTypeArgsForTypeVarTuple(getTypeArgs(node, flags), typeParams, node);
4889
4902
  let reportedError = false;
4890
4903
  // PEP 612 says that if the class has only one type parameter consisting
@@ -4992,7 +5005,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
4992
5005
  else if (param.shared.isDefaultExplicit) {
4993
5006
  typeArgType = solveAndApplyConstraints(param, constraints, {
4994
5007
  replaceUnsolved: {
4995
- scopeIds: [aliasInfo.typeVarScopeId],
5008
+ scopeIds: [aliasInfo.shared.typeVarScopeId],
4996
5009
  tupleClassType: getTupleClassType(),
4997
5010
  },
4998
5011
  });
@@ -5029,7 +5042,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
5029
5042
  }
5030
5043
  const solutionSet = (0, constraintSolver_1.solveConstraints)(evaluatorInterface, constraints).getMainSolutionSet();
5031
5044
  const aliasTypeArgs = [];
5032
- (_f = aliasInfo.typeParams) === null || _f === void 0 ? void 0 : _f.forEach((typeParam) => {
5045
+ (_f = aliasInfo.shared.typeParams) === null || _f === void 0 ? void 0 : _f.forEach((typeParam) => {
5033
5046
  let typeVarType = solutionSet.getType(typeParam);
5034
5047
  // Fill in any unsolved type arguments with unknown.
5035
5048
  if (!typeVarType) {
@@ -5068,7 +5081,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
5068
5081
  types_1.ClassType.isBuiltIn(baseTypeResult.type, 'TypeAliasType') &&
5069
5082
  ((_b = baseTypeResult.type.props) === null || _b === void 0 ? void 0 : _b.typeForm)) {
5070
5083
  const typeAliasInfo = (_c = baseTypeResult.type.props.typeForm.props) === null || _c === void 0 ? void 0 : _c.typeAliasInfo;
5071
- if (typeAliasInfo && typeAliasInfo.typeParams) {
5084
+ if (typeAliasInfo && typeAliasInfo.shared.typeParams) {
5072
5085
  const origTypeAlias = types_1.TypeBase.cloneForTypeAlias((0, typeUtils_1.convertToInstantiable)(baseTypeResult.type.props.typeForm), { ...typeAliasInfo, typeArgs: undefined });
5073
5086
  const typeFormType = createSpecializedTypeAlias(node, origTypeAlias, flags);
5074
5087
  if (typeFormType) {
@@ -5081,14 +5094,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
5081
5094
  if ((0, types_1.isTypeVar)(baseTypeResult.type) && (0, typeUtils_1.isTypeAliasPlaceholder)(baseTypeResult.type)) {
5082
5095
  const typeArgTypes = getTypeArgs(node, flags).map((t) => (0, typeUtils_1.convertToInstance)(t.type));
5083
5096
  const type = types_1.TypeBase.cloneForTypeAlias(baseTypeResult.type, {
5084
- name: baseTypeResult.type.shared.recursiveAlias.name,
5085
- fullName: '',
5086
- moduleName: '',
5087
- fileUri: uri_1.Uri.empty(),
5088
- typeVarScopeId: baseTypeResult.type.shared.recursiveAlias.scopeId,
5089
- isPep695Syntax: !!baseTypeResult.type.shared.recursiveAlias.isPep695Syntax,
5090
- typeParams: baseTypeResult.type.shared.recursiveAlias.typeParams,
5091
- usageVariance: undefined,
5097
+ shared: baseTypeResult.type.shared.recursiveAlias,
5092
5098
  typeArgs: typeArgTypes,
5093
5099
  });
5094
5100
  return { type };
@@ -5256,31 +5262,38 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
5256
5262
  var _a;
5257
5263
  const aliasInfo = (_a = type.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo;
5258
5264
  // If this isn't a generic type alias, there's nothing to do.
5259
- if (!aliasInfo || !aliasInfo.typeParams) {
5265
+ if (!aliasInfo || !aliasInfo.shared.typeParams) {
5260
5266
  return undefined;
5261
5267
  }
5262
- // Is the usage variance info already cached?
5263
- if (aliasInfo.usageVariance) {
5264
- return aliasInfo.usageVariance;
5268
+ // Is the computed variance info already cached?
5269
+ if (aliasInfo.shared.computedVariance) {
5270
+ return aliasInfo.shared.computedVariance;
5265
5271
  }
5266
- const typeParams = aliasInfo.typeParams;
5272
+ const typeParams = aliasInfo.shared.typeParams;
5267
5273
  // Start with all of the usage variances unknown.
5268
5274
  const usageVariances = typeParams.map(() => 1 /* Variance.Unknown */);
5269
5275
  // Prepopulate the cached value for the type alias to handle
5270
5276
  // recursive type aliases.
5271
- aliasInfo.usageVariance = usageVariances;
5277
+ aliasInfo.shared.computedVariance = usageVariances;
5272
5278
  // Traverse the type alias type definition and adjust the usage
5273
5279
  // variances accordingly.
5274
- updateUsageVariancesRecursive(type, typeParams, usageVariances);
5280
+ updateUsageVariancesRecursive(type, typeParams, usageVariances, 3 /* Variance.Covariant */);
5275
5281
  return usageVariances;
5276
5282
  }
5277
5283
  // Looks at uses of the type parameters within the type and adjusts the
5278
5284
  // variances accordingly. For example, if the type is `Mapping[T1, T2]`,
5279
5285
  // then T1 will be set to invariant and T2 will be set to covariant.
5280
- function updateUsageVariancesRecursive(type, typeAliasTypeParams, usageVariances, recursionCount = 0) {
5286
+ function updateUsageVariancesRecursive(type, typeAliasTypeParams, usageVariances, varianceContext, recursionCount = 0) {
5281
5287
  if (recursionCount > types_1.maxTypeRecursionCount) {
5282
5288
  return;
5283
5289
  }
5290
+ const transformedType = (0, typeUtils_1.transformPossibleRecursiveTypeAlias)(type);
5291
+ // If this is a recursive type alias, use a lower recursion limit.
5292
+ if (transformedType !== type) {
5293
+ if (recursionCount > maxRecursiveTypeAliasRecursionCount) {
5294
+ return;
5295
+ }
5296
+ }
5284
5297
  recursionCount++;
5285
5298
  // Define a helper function that performs the actual usage variant update.
5286
5299
  function updateUsageVarianceForType(type, variance) {
@@ -5290,20 +5303,19 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
5290
5303
  usageVariances[typeParamIndex] = (0, typeUtils_1.combineVariances)(usageVariances[typeParamIndex], variance);
5291
5304
  }
5292
5305
  else {
5293
- updateUsageVariancesRecursive(subtype, typeAliasTypeParams, usageVariances, recursionCount);
5306
+ updateUsageVariancesRecursive(subtype, typeAliasTypeParams, usageVariances, variance, recursionCount);
5294
5307
  }
5295
5308
  });
5296
5309
  }
5297
- (0, typeUtils_1.doForEachSubtype)(type, (subtype) => {
5310
+ (0, typeUtils_1.doForEachSubtype)(transformedType, (subtype) => {
5298
5311
  if (subtype.category === 4 /* TypeCategory.Function */) {
5299
- if (subtype.priv.specializedTypes) {
5300
- subtype.priv.specializedTypes.parameterTypes.forEach((paramType) => {
5301
- updateUsageVarianceForType(paramType, 4 /* Variance.Contravariant */);
5302
- });
5303
- const returnType = subtype.priv.specializedTypes.returnType;
5304
- if (returnType) {
5305
- updateUsageVarianceForType(returnType, 3 /* Variance.Covariant */);
5306
- }
5312
+ subtype.shared.parameters.forEach((param, index) => {
5313
+ const paramType = types_1.FunctionType.getParamType(subtype, index);
5314
+ updateUsageVarianceForType(paramType, (0, typeUtils_1.invertVariance)(varianceContext));
5315
+ });
5316
+ const returnType = types_1.FunctionType.getEffectiveReturnType(subtype);
5317
+ if (returnType) {
5318
+ updateUsageVarianceForType(returnType, varianceContext);
5307
5319
  }
5308
5320
  }
5309
5321
  else if (subtype.category === 6 /* TypeCategory.Class */) {
@@ -5316,7 +5328,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
5316
5328
  subtype.priv.typeArgs.forEach((typeArg, classParamIndex) => {
5317
5329
  var _a;
5318
5330
  if ((0, typeUtils_1.isTupleClass)(subtype)) {
5319
- updateUsageVarianceForType(typeArg, 3 /* Variance.Covariant */);
5331
+ updateUsageVarianceForType(typeArg, varianceContext);
5320
5332
  }
5321
5333
  else if (classParamIndex < subtype.shared.typeParams.length) {
5322
5334
  const classTypeParam = subtype.shared.typeParams[classParamIndex];
@@ -5326,7 +5338,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
5326
5338
  });
5327
5339
  }
5328
5340
  else {
5329
- updateUsageVarianceForType(typeArg, (_a = classTypeParam.priv.computedVariance) !== null && _a !== void 0 ? _a : classTypeParam.shared.declaredVariance);
5341
+ const effectiveVariance = (_a = classTypeParam.priv.computedVariance) !== null && _a !== void 0 ? _a : classTypeParam.shared.declaredVariance;
5342
+ updateUsageVarianceForType(typeArg, varianceContext === 4 /* Variance.Contravariant */
5343
+ ? (0, typeUtils_1.invertVariance)(effectiveVariance)
5344
+ : effectiveVariance);
5330
5345
  }
5331
5346
  }
5332
5347
  });
@@ -7380,11 +7395,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
7380
7395
  paramDetails.params.forEach((paramInfo) => {
7381
7396
  (0, debug_1.assert)(paramInfo !== undefined, 'paramInfo is undefined for param name map');
7382
7397
  const param = paramInfo.param;
7383
- if (param.name && param.category === 0 /* ParamCategory.Simple */) {
7398
+ if (param.name && param.category === 0 /* ParamCategory.Simple */ && paramInfo.kind !== parameterUtils_1.ParamKind.Positional) {
7384
7399
  paramMap.set(param.name, {
7385
7400
  argsNeeded: param.category === 0 /* ParamCategory.Simple */ && !paramInfo.defaultType ? 1 : 0,
7386
7401
  argsReceived: 0,
7387
- isPositionalOnly: paramInfo.kind === parameterUtils_1.ParamKind.Positional,
7388
7402
  });
7389
7403
  }
7390
7404
  });
@@ -7696,19 +7710,20 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
7696
7710
  }
7697
7711
  }
7698
7712
  else {
7699
- const paramName = paramDetails.params[paramIndex].param.name;
7713
+ const paramInfo = paramDetails.params[paramIndex];
7714
+ const paramName = paramInfo.param.name;
7700
7715
  validateArgTypeParams.push({
7701
- paramCategory: paramDetails.params[paramIndex].param.category,
7716
+ paramCategory: paramInfo.param.category,
7702
7717
  paramType,
7703
7718
  requiresTypeVarMatching: (0, typeUtils_1.requiresSpecialization)(paramType),
7704
7719
  argument: argList[argIndex],
7705
7720
  errorNode: argList[argIndex].valueExpression || errorNode,
7706
7721
  paramName,
7707
- isParamNameSynthesized: types_1.FunctionParam.isNameSynthesized(paramDetails.params[paramIndex].param),
7722
+ isParamNameSynthesized: types_1.FunctionParam.isNameSynthesized(paramInfo.param),
7708
7723
  });
7709
- trySetActive(argList[argIndex], paramDetails.params[paramIndex].param);
7724
+ trySetActive(argList[argIndex], paramInfo.param);
7710
7725
  // Note that the parameter has received an argument.
7711
- if (paramName && paramMap.has(paramName)) {
7726
+ if (paramName && paramMap.has(paramName) && paramInfo.kind !== parameterUtils_1.ParamKind.Positional) {
7712
7727
  paramMap.get(paramName).argsReceived++;
7713
7728
  }
7714
7729
  argIndex++;
@@ -7786,7 +7801,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
7786
7801
  tdEntries.knownItems.forEach((entry, name) => {
7787
7802
  var _a, _b;
7788
7803
  const paramEntry = paramMap.get(name);
7789
- if (paramEntry && !paramEntry.isPositionalOnly) {
7804
+ if (paramEntry) {
7790
7805
  if (paramEntry.argsReceived > 0) {
7791
7806
  diag.addMessage(localize_1.LocMessage.paramAlreadyAssigned().format({ name }));
7792
7807
  }
@@ -7825,7 +7840,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
7825
7840
  paramMap.set(name, {
7826
7841
  argsNeeded: 1,
7827
7842
  argsReceived: 1,
7828
- isPositionalOnly: false,
7829
7843
  });
7830
7844
  }
7831
7845
  else {
@@ -7944,7 +7958,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
7944
7958
  if (paramName) {
7945
7959
  const paramNameValue = paramName.d.value;
7946
7960
  const paramEntry = paramMap.get(paramNameValue);
7947
- if (paramEntry && !paramEntry.isPositionalOnly) {
7961
+ if (paramEntry) {
7948
7962
  if (paramEntry.argsReceived > 0) {
7949
7963
  if (!canSkipDiagnosticForNode(errorNode) && !isTypeIncomplete) {
7950
7964
  addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.paramAlreadyAssigned().format({ name: paramNameValue }), paramName);
@@ -7953,7 +7967,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
7953
7967
  }
7954
7968
  else {
7955
7969
  paramEntry.argsReceived++;
7956
- const paramInfoIndex = paramDetails.params.findIndex((paramInfo) => paramInfo.param.name === paramNameValue);
7970
+ const paramInfoIndex = paramDetails.params.findIndex((paramInfo) => paramInfo.param.name === paramNameValue &&
7971
+ paramInfo.kind !== parameterUtils_1.ParamKind.Positional);
7957
7972
  (0, debug_1.assert)(paramInfoIndex >= 0);
7958
7973
  const paramType = paramDetails.params[paramInfoIndex].type;
7959
7974
  validateArgTypeParams.push({
@@ -7991,7 +8006,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
7991
8006
  paramMap.set(paramNameValue, {
7992
8007
  argsNeeded: 1,
7993
8008
  argsReceived: 1,
7994
- isPositionalOnly: false,
7995
8009
  });
7996
8010
  (0, debug_1.assert)(paramDetails.params[paramDetails.kwargsIndex], 'paramDetails.kwargsIndex params entry is undefined');
7997
8011
  }
@@ -8105,7 +8119,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
8105
8119
  const param = paramInfo.param;
8106
8120
  if (param.category === 0 /* ParamCategory.Simple */ && param.name) {
8107
8121
  const entry = paramMap.get(param.name);
8108
- if (entry.argsNeeded === 0 && entry.argsReceived === 0) {
8122
+ if (entry && entry.argsNeeded === 0 && entry.argsReceived === 0) {
8109
8123
  const defaultArgType = paramInfo.defaultType;
8110
8124
  if (defaultArgType &&
8111
8125
  !(0, typeUtils_1.isEllipsisType)(defaultArgType) &&
@@ -11446,7 +11460,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
11446
11460
  }
11447
11461
  return createSpecialType(classType, typeArgs, /* paramLimit */ undefined, /* allowParamSpec */ true);
11448
11462
  }
11449
- function transformTypeForTypeAlias(type, name, errorNode, isPep695Syntax, isPep695TypeVarType, typeParams, typeParamNodes) {
11463
+ function transformTypeForTypeAlias(type, errorNode, typeAliasPlaceholder, isPep695TypeVarType, typeParamNodes) {
11450
11464
  var _a;
11451
11465
  if (!types_1.TypeBase.isInstantiable(type)) {
11452
11466
  return type;
@@ -11456,6 +11470,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
11456
11470
  if ((0, typeUtils_1.isTypeAliasPlaceholder)(type)) {
11457
11471
  return type;
11458
11472
  }
11473
+ const sharedInfo = typeAliasPlaceholder.shared.recursiveAlias;
11474
+ (0, debug_1.assert)(sharedInfo !== undefined);
11475
+ let typeParams = sharedInfo.typeParams;
11459
11476
  if (!typeParams) {
11460
11477
  // Determine if there are any generic type parameters associated
11461
11478
  // with this type alias.
@@ -11480,10 +11497,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
11480
11497
  addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typeVarWithDefaultFollowsVariadic().format({
11481
11498
  typeVarName: typeParams[typeVarWithDefaultIndex].shared.name,
11482
11499
  variadicName: typeParams[firstTypeVarTupleIndex].shared.name,
11483
- }), typeParamNodes ? typeParamNodes[typeVarWithDefaultIndex].d.name : name);
11500
+ }), typeParamNodes ? typeParamNodes[typeVarWithDefaultIndex].d.name : errorNode);
11484
11501
  }
11485
11502
  }
11486
- const typeAliasScopeId = ParseTreeUtils.getScopeIdForNode(name);
11487
11503
  // Validate the default types for all type parameters.
11488
11504
  typeParams.forEach((typeParam, index) => {
11489
11505
  var _a;
@@ -11492,7 +11508,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
11492
11508
  if (typeParamNodes && index < typeParamNodes.length) {
11493
11509
  bestErrorNode = (_a = typeParamNodes[index].d.defaultExpr) !== null && _a !== void 0 ? _a : typeParamNodes[index].d.name;
11494
11510
  }
11495
- validateTypeParamDefault(bestErrorNode, typeParam, typeParams.slice(0, index), typeAliasScopeId);
11511
+ validateTypeParamDefault(bestErrorNode, typeParam, typeParams.slice(0, index), sharedInfo.typeVarScopeId);
11496
11512
  });
11497
11513
  // Verify that we have at most one TypeVarTuple.
11498
11514
  const variadics = typeParams.filter((param) => (0, types_1.isTypeVarTuple)(param));
@@ -11501,29 +11517,23 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
11501
11517
  names: variadics.map((v) => `"${v.shared.name}"`).join(', '),
11502
11518
  }), errorNode);
11503
11519
  }
11504
- if (!isPep695Syntax && !isPep695TypeVarType) {
11505
- const boundTypeVars = typeParams.filter((typeVar) => typeVar.priv.scopeId !== typeAliasScopeId && typeVar.priv.scopeType === 0 /* TypeVarScopeType.Class */);
11520
+ if (!sharedInfo.isPep695Syntax && !isPep695TypeVarType) {
11521
+ const boundTypeVars = typeParams.filter((typeVar) => typeVar.priv.scopeId !== sharedInfo.typeVarScopeId &&
11522
+ typeVar.priv.scopeType === 0 /* TypeVarScopeType.Class */);
11506
11523
  if (boundTypeVars.length > 0) {
11507
11524
  addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeForm, localize_1.LocMessage.genericTypeAliasBoundTypeVar().format({
11508
11525
  names: boundTypeVars.map((t) => `${t.shared.name}`).join(', '),
11509
11526
  }), errorNode);
11510
11527
  }
11511
11528
  }
11512
- const fileInfo = AnalyzerNodeInfo.getFileInfo(name);
11529
+ sharedInfo.typeParams = typeParams.length > 0 ? typeParams : undefined;
11513
11530
  let typeAlias = types_1.TypeBase.cloneForTypeAlias(type, {
11514
- name: name.d.value,
11515
- fullName: ParseTreeUtils.getClassFullName(name, fileInfo.moduleName, name.d.value),
11516
- moduleName: fileInfo.moduleName,
11517
- fileUri: fileInfo.fileUri,
11518
- typeVarScopeId: typeAliasScopeId,
11519
- isPep695Syntax,
11520
- typeParams: typeParams.length > 0 ? typeParams : undefined,
11521
- usageVariance: undefined,
11531
+ shared: sharedInfo,
11522
11532
  typeArgs: undefined,
11523
11533
  });
11524
11534
  // All PEP 695 type aliases are special forms because they are
11525
11535
  // TypeAliasType objects at runtime.
11526
- if (isPep695Syntax || isPep695TypeVarType) {
11536
+ if (sharedInfo.isPep695Syntax || isPep695TypeVarType) {
11527
11537
  const typeAliasTypeClass = getTypingType(errorNode, 'TypeAliasType');
11528
11538
  if (typeAliasTypeClass && (0, types_1.isInstantiableClass)(typeAliasTypeClass)) {
11529
11539
  typeAlias = types_1.TypeBase.cloneAsSpecialForm(typeAlias, types_1.ClassType.cloneAsInstance(typeAliasTypeClass));
@@ -11654,7 +11664,16 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
11654
11664
  typeParamVariance: 2 /* Variance.Invariant */,
11655
11665
  },
11656
11666
  ],
11657
- ['TypeForm', { alias: '', module: 'builtins', isSpecialForm: true, typeParamVariance: 3 /* Variance.Covariant */ }],
11667
+ [
11668
+ 'TypeForm',
11669
+ {
11670
+ alias: '',
11671
+ module: 'builtins',
11672
+ isSpecialForm: true,
11673
+ typeParamVariance: 3 /* Variance.Covariant */,
11674
+ isIllegalInIsinstance: true,
11675
+ },
11676
+ ],
11658
11677
  ]);
11659
11678
  const aliasMapEntry = specialTypes.get(assignedName);
11660
11679
  if (aliasMapEntry) {
@@ -11793,7 +11812,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
11793
11812
  }
11794
11813
  }
11795
11814
  if (typeAliasNameNode) {
11796
- typeAliasPlaceholder = synthesizeTypeAliasPlaceholder(typeAliasNameNode);
11815
+ typeAliasPlaceholder = synthesizeTypeAliasPlaceholder(typeAliasNameNode, /* isPep695Syntax */ false);
11797
11816
  writeTypeCache(node, { type: typeAliasPlaceholder }, /* flags */ undefined);
11798
11817
  writeTypeCache(node.d.leftExpr, { type: typeAliasPlaceholder }, /* flags */ undefined);
11799
11818
  if (node.d.leftExpr.nodeType === 54 /* ParseNodeType.TypeAnnotation */) {
@@ -11814,8 +11833,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
11814
11833
  if (typeAliasNameNode) {
11815
11834
  (0, debug_1.assert)(typeAliasPlaceholder !== undefined);
11816
11835
  // If this is a type alias, record its name based on the assignment target.
11817
- rightHandType = transformTypeForTypeAlias(rightHandType, typeAliasNameNode, typeAliasNameNode,
11818
- /* isPep695Syntax */ false,
11836
+ rightHandType = transformTypeForTypeAlias(rightHandType, typeAliasNameNode, typeAliasPlaceholder,
11819
11837
  /* isPep695TypeVarType */ false);
11820
11838
  if ((0, typeUtils_1.isTypeAliasRecursive)(typeAliasPlaceholder, rightHandType)) {
11821
11839
  addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typeAliasIsRecursiveDirect().format({
@@ -11828,7 +11846,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
11828
11846
  typeAliasPlaceholder.shared.boundType = rightHandType;
11829
11847
  // Record the type parameters within the recursive type alias so it
11830
11848
  // can be specialized.
11831
- typeAliasPlaceholder.shared.recursiveAlias.typeParams = (_b = (_a = rightHandType.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo) === null || _b === void 0 ? void 0 : _b.typeParams;
11849
+ typeAliasPlaceholder.shared.recursiveAlias.typeParams =
11850
+ (_b = (_a = rightHandType.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo) === null || _b === void 0 ? void 0 : _b.shared.typeParams;
11832
11851
  }
11833
11852
  else {
11834
11853
  // If the RHS is a constant boolean expression, assign it a literal type.
@@ -11848,17 +11867,22 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
11848
11867
  }
11849
11868
  // Synthesize a TypeVar that acts as a placeholder for a type alias. This allows
11850
11869
  // the type alias definition to refer to itself.
11851
- function synthesizeTypeAliasPlaceholder(nameNode) {
11870
+ function synthesizeTypeAliasPlaceholder(nameNode, isPep695Syntax) {
11852
11871
  const placeholder = types_1.TypeVarType.createInstantiable(`__type_alias_${nameNode.d.value}`);
11853
11872
  placeholder.shared.isSynthesized = true;
11854
- const scopeId = ParseTreeUtils.getScopeIdForNode(nameNode);
11873
+ const typeVarScopeId = ParseTreeUtils.getScopeIdForNode(nameNode);
11874
+ const fileInfo = AnalyzerNodeInfo.getFileInfo(nameNode);
11855
11875
  placeholder.shared.recursiveAlias = {
11856
11876
  name: nameNode.d.value,
11857
- scopeId,
11858
- isPep695Syntax: false,
11877
+ fullName: ParseTreeUtils.getClassFullName(nameNode, fileInfo.moduleName, nameNode.d.value),
11878
+ moduleName: fileInfo.moduleName,
11879
+ fileUri: fileInfo.fileUri,
11880
+ typeVarScopeId,
11881
+ isPep695Syntax,
11859
11882
  typeParams: undefined,
11883
+ computedVariance: undefined,
11860
11884
  };
11861
- placeholder.priv.scopeId = scopeId;
11885
+ placeholder.priv.scopeId = typeVarScopeId;
11862
11886
  return placeholder;
11863
11887
  }
11864
11888
  // Evaluates the type of a type alias (i.e. "type") statement. This code
@@ -11883,7 +11907,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
11883
11907
  }
11884
11908
  // Synthesize a type variable that represents the type alias while we're
11885
11909
  // evaluating it. This allows us to handle recursive definitions.
11886
- const typeAliasTypeVar = synthesizeTypeAliasPlaceholder(nameNode);
11910
+ const typeAliasTypeVar = synthesizeTypeAliasPlaceholder(nameNode, isPep695Syntax);
11887
11911
  // Write the type to the type cache to support recursive type alias definitions.
11888
11912
  writeTypeCache(nameNode, { type: typeAliasTypeVar }, /* flags */ undefined);
11889
11913
  // Set a partial type to handle recursive (self-referential) type aliases.
@@ -11906,8 +11930,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
11906
11930
  if (aliasTypeResult.isIncomplete) {
11907
11931
  isIncomplete = true;
11908
11932
  }
11909
- aliasType = transformTypeForTypeAlias(aliasType, nameNode, nameNode, isPep695Syntax,
11910
- /* isPep695TypeVarType */ true, typeParams, typeParamNodes);
11933
+ aliasType = transformTypeForTypeAlias(aliasType, nameNode, typeAliasTypeVar,
11934
+ /* isPep695TypeVarType */ true, typeParamNodes);
11911
11935
  // See if the type alias relies on itself in a way that cannot be resolved.
11912
11936
  if ((0, typeUtils_1.isTypeAliasRecursive)(typeAliasTypeVar, aliasType)) {
11913
11937
  addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typeAliasIsRecursiveDirect().format({
@@ -12804,7 +12828,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
12804
12828
  const paramMap = new Map();
12805
12829
  for (let i = paramListDetails.firstKeywordOnlyIndex; i < paramListDetails.params.length; i++) {
12806
12830
  const paramInfo = paramListDetails.params[i];
12807
- if (paramInfo.param.category === 0 /* ParamCategory.Simple */ && paramInfo.param.name) {
12831
+ if (paramInfo.param.category === 0 /* ParamCategory.Simple */ &&
12832
+ paramInfo.param.name &&
12833
+ paramInfo.kind !== parameterUtils_1.ParamKind.Positional) {
12808
12834
  paramMap.set(paramInfo.param.name, i);
12809
12835
  }
12810
12836
  }
@@ -15795,6 +15821,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
15795
15821
  else {
15796
15822
  (0, debug_1.assert)(scopeNode.nodeType === 77 /* ParseNodeType.TypeAlias */);
15797
15823
  scopeType = 2 /* TypeVarScopeType.TypeAlias */;
15824
+ typeVar.shared.declaredVariance = 0 /* Variance.Auto */;
15798
15825
  }
15799
15826
  typeVar = types_1.TypeVarType.cloneForScopeId(typeVar, ParseTreeUtils.getScopeIdForNode(scopeNode.nodeType === 77 /* ParseNodeType.TypeAlias */ ? scopeNode.d.name : scopeNode), scopeNode.d.name.d.value, scopeType);
15800
15827
  }
@@ -15931,8 +15958,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
15931
15958
  // in the event that its inferred type is instantiable or explicitly Any
15932
15959
  // (but not an ellipsis).
15933
15960
  if (isLegalImplicitTypeAliasType(inferredType)) {
15934
- inferredType = transformTypeForTypeAlias(inferredType, resolvedDecl.typeAliasName, resolvedDecl.node,
15935
- /* isPep695Syntax */ false,
15961
+ const typeAliasTypeVar = synthesizeTypeAliasPlaceholder(resolvedDecl.typeAliasName,
15962
+ /* isPep695Syntax */ false);
15963
+ inferredType = transformTypeForTypeAlias(inferredType, resolvedDecl.node, typeAliasTypeVar,
15936
15964
  /* isPep695TypeVarType */ false);
15937
15965
  isUnambiguousType = true;
15938
15966
  }
@@ -17179,16 +17207,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
17179
17207
  // Do the source and dest refer to the same recursive type alias?
17180
17208
  if ((destAliasInfo === null || destAliasInfo === void 0 ? void 0 : destAliasInfo.typeArgs) &&
17181
17209
  (srcAliasInfo === null || srcAliasInfo === void 0 ? void 0 : srcAliasInfo.typeArgs) &&
17182
- destType.shared.recursiveAlias.scopeId === srcType.shared.recursiveAlias.scopeId) {
17183
- let isAssignable = true;
17184
- const srcTypeArgs = srcAliasInfo.typeArgs;
17185
- destAliasInfo.typeArgs.forEach((destTypeArg, index) => {
17186
- const srcTypeArg = index < srcTypeArgs.length ? srcTypeArgs[index] : types_1.UnknownType.create();
17187
- if (!assignType(destTypeArg, srcTypeArg, diag, constraints, flags, recursionCount)) {
17188
- isAssignable = false;
17189
- }
17190
- });
17191
- return isAssignable;
17210
+ destType.shared.recursiveAlias.typeVarScopeId === srcType.shared.recursiveAlias.typeVarScopeId) {
17211
+ return assignRecursiveTypeAliasToSelf(destAliasInfo, srcAliasInfo, diag, constraints, flags, recursionCount);
17192
17212
  }
17193
17213
  else {
17194
17214
  // Have we already recursed once?
@@ -17704,6 +17724,31 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
17704
17724
  diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocAddendum.typeAssignmentMismatch().format(printSrcDestTypes(srcType, destType)));
17705
17725
  return false;
17706
17726
  }
17727
+ // Determines whether a recursive type alias can be assigned to itself
17728
+ // given the source and dest type args and computed variance for its
17729
+ // type params.
17730
+ function assignRecursiveTypeAliasToSelf(destAliasInfo, srcAliasInfo, diag, constraints, flags = 0 /* AssignTypeFlags.Default */, recursionCount = 0) {
17731
+ (0, debug_1.assert)(destAliasInfo.typeArgs !== undefined);
17732
+ (0, debug_1.assert)(srcAliasInfo.typeArgs !== undefined);
17733
+ let isAssignable = true;
17734
+ const srcTypeArgs = srcAliasInfo.typeArgs;
17735
+ const variances = destAliasInfo.shared.computedVariance;
17736
+ destAliasInfo.typeArgs.forEach((destTypeArg, index) => {
17737
+ const srcTypeArg = index < srcTypeArgs.length ? srcTypeArgs[index] : types_1.UnknownType.create();
17738
+ let adjFlags = flags;
17739
+ const variance = variances && index < variances.length ? variances[index] : 3 /* Variance.Covariant */;
17740
+ if (variance === 2 /* Variance.Invariant */) {
17741
+ adjFlags |= 1 /* AssignTypeFlags.Invariant */;
17742
+ }
17743
+ else if (variance === 4 /* Variance.Contravariant */) {
17744
+ adjFlags ^= 2 /* AssignTypeFlags.Contravariant */;
17745
+ }
17746
+ if (!assignType(destTypeArg, srcTypeArg, diag, constraints, adjFlags, recursionCount)) {
17747
+ isAssignable = false;
17748
+ }
17749
+ });
17750
+ return isAssignable;
17751
+ }
17707
17752
  // If the expected type is an explicit TypeForm type, see if the source
17708
17753
  // type has an implicit TypeForm type that can be assigned to it. If so,
17709
17754
  // convert to an explicit TypeForm type.
@@ -18599,7 +18644,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
18599
18644
  if (destParamDetails.firstKeywordOnlyIndex !== undefined) {
18600
18645
  destParamDetails.params.forEach((param, index) => {
18601
18646
  if (index >= destParamDetails.firstKeywordOnlyIndex) {
18602
- if (param.param.name && param.param.category === 0 /* ParamCategory.Simple */) {
18647
+ if (param.param.name &&
18648
+ param.param.category === 0 /* ParamCategory.Simple */ &&
18649
+ param.kind !== parameterUtils_1.ParamKind.Positional) {
18603
18650
  destParamMap.set(param.param.name, param);
18604
18651
  }
18605
18652
  }