@zzzen/pyright-internal 1.2.0-dev.20231210 → 1.2.0-dev.20231217

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 (71) hide show
  1. package/dist/analyzer/binder.js +12 -11
  2. package/dist/analyzer/binder.js.map +1 -1
  3. package/dist/analyzer/codeFlowEngine.js +18 -11
  4. package/dist/analyzer/codeFlowEngine.js.map +1 -1
  5. package/dist/analyzer/codeFlowTypes.d.ts +0 -1
  6. package/dist/analyzer/codeFlowTypes.js.map +1 -1
  7. package/dist/analyzer/decorators.js +14 -43
  8. package/dist/analyzer/decorators.js.map +1 -1
  9. package/dist/analyzer/importResolver.js +1 -1
  10. package/dist/analyzer/importResolver.js.map +1 -1
  11. package/dist/analyzer/packageTypeVerifier.js +1 -1
  12. package/dist/analyzer/packageTypeVerifier.js.map +1 -1
  13. package/dist/analyzer/parseTreeUtils.js +1 -1
  14. package/dist/analyzer/parseTreeUtils.js.map +1 -1
  15. package/dist/analyzer/patternMatching.js +23 -0
  16. package/dist/analyzer/patternMatching.js.map +1 -1
  17. package/dist/analyzer/properties.js +3 -0
  18. package/dist/analyzer/properties.js.map +1 -1
  19. package/dist/analyzer/service.js +12 -10
  20. package/dist/analyzer/service.js.map +1 -1
  21. package/dist/analyzer/sourceMapper.js +3 -2
  22. package/dist/analyzer/sourceMapper.js.map +1 -1
  23. package/dist/analyzer/typeEvaluator.js +87 -50
  24. package/dist/analyzer/typeEvaluator.js.map +1 -1
  25. package/dist/analyzer/typeGuards.d.ts +1 -0
  26. package/dist/analyzer/typeGuards.js +2 -1
  27. package/dist/analyzer/typeGuards.js.map +1 -1
  28. package/dist/analyzer/typeUtils.d.ts +1 -0
  29. package/dist/analyzer/typeUtils.js +24 -8
  30. package/dist/analyzer/typeUtils.js.map +1 -1
  31. package/dist/analyzer/types.d.ts +5 -2
  32. package/dist/analyzer/types.js +3 -1
  33. package/dist/analyzer/types.js.map +1 -1
  34. package/dist/common/fileWatcher.d.ts +1 -1
  35. package/dist/common/realFileSystem.js +1 -1
  36. package/dist/common/realFileSystem.js.map +1 -1
  37. package/dist/common/uri/emptyUri.js +1 -25
  38. package/dist/common/uri/emptyUri.js.map +1 -1
  39. package/dist/common/workspaceEditUtils.js +3 -3
  40. package/dist/common/workspaceEditUtils.js.map +1 -1
  41. package/dist/languageService/symbolIndexer.js +10 -2
  42. package/dist/languageService/symbolIndexer.js.map +1 -1
  43. package/dist/localization/localize.d.ts +1 -0
  44. package/dist/localization/localize.js +1 -0
  45. package/dist/localization/localize.js.map +1 -1
  46. package/dist/localization/package.nls.en-us.json +1 -0
  47. package/dist/parser/parseNodes.d.ts +1 -0
  48. package/dist/parser/parseNodes.js +1 -0
  49. package/dist/parser/parseNodes.js.map +1 -1
  50. package/dist/parser/parser.js +18 -15
  51. package/dist/parser/parser.js.map +1 -1
  52. package/dist/pyright.js +3 -3
  53. package/dist/pyright.js.map +1 -1
  54. package/dist/tests/classDeclaration.test.d.ts +1 -0
  55. package/dist/tests/classDeclaration.test.js +166 -0
  56. package/dist/tests/classDeclaration.test.js.map +1 -0
  57. package/dist/tests/harness/fourslash/workspaceEditTestUtils.js +4 -0
  58. package/dist/tests/harness/fourslash/workspaceEditTestUtils.js.map +1 -1
  59. package/dist/tests/harness/vfs/filesystem.js +1 -1
  60. package/dist/tests/harness/vfs/filesystem.js.map +1 -1
  61. package/dist/tests/importResolver.test.js +25 -0
  62. package/dist/tests/importResolver.test.js.map +1 -1
  63. package/dist/tests/sourceMapperUtils.test.js +60 -29
  64. package/dist/tests/sourceMapperUtils.test.js.map +1 -1
  65. package/dist/tests/typeEvaluator2.test.js +4 -0
  66. package/dist/tests/typeEvaluator2.test.js.map +1 -1
  67. package/dist/tests/typeEvaluator3.test.js +13 -1
  68. package/dist/tests/typeEvaluator3.test.js.map +1 -1
  69. package/dist/tests/typeEvaluator4.test.js +9 -1
  70. package/dist/tests/typeEvaluator4.test.js.map +1 -1
  71. package/package.json +1 -1
@@ -622,6 +622,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
622
622
  break;
623
623
  }
624
624
  case 4 /* ParseNodeType.AssignmentExpression */: {
625
+ if ((flags & 256 /* EvaluatorFlags.ExpectingTypeAnnotation */) !== 0) {
626
+ addError(localize_1.Localizer.Diagnostic.walrusNotAllowed(), node);
627
+ }
625
628
  typeResult = getTypeOfExpression(node.rightExpression, flags, inferenceContext);
626
629
  assignTypeToExpression(node.name, typeResult.type, !!typeResult.isIncomplete, node.rightExpression,
627
630
  /* ignoreEmptyContainers */ true);
@@ -761,6 +764,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
761
764
  }
762
765
  }
763
766
  function getTypeOfAwaitOperator(node, flags, inferenceContext) {
767
+ if ((flags & 256 /* EvaluatorFlags.ExpectingTypeAnnotation */) !== 0) {
768
+ addError(localize_1.Localizer.Diagnostic.awaitNotAllowed(), node);
769
+ return { type: types_1.UnknownType.create() };
770
+ }
764
771
  const effectiveExpectedType = inferenceContext
765
772
  ? createAwaitableReturnType(node, inferenceContext.expectedType,
766
773
  /* isGenerator */ false,
@@ -815,24 +822,26 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
815
822
  !iterType.isVariadicUnpacked) {
816
823
  typeResult = { type: types_1.TypeVarType.cloneForUnpacked(iterType) };
817
824
  }
825
+ else if ((flags & 2097152 /* EvaluatorFlags.AllowUnpackedTupleOrTypeVarTuple */) !== 0 &&
826
+ (0, types_1.isInstantiableClass)(iterType) &&
827
+ types_1.ClassType.isBuiltIn(iterType, 'tuple')) {
828
+ typeResult = { type: types_1.ClassType.cloneForUnpacked(iterType) };
829
+ }
830
+ else if ((flags & 256 /* EvaluatorFlags.ExpectingTypeAnnotation */) !== 0) {
831
+ addError(localize_1.Localizer.Diagnostic.unpackInAnnotation(), node, node.starToken);
832
+ typeResult = { type: types_1.UnknownType.create() };
833
+ }
818
834
  else {
819
- if ((flags & 2097152 /* EvaluatorFlags.AllowUnpackedTupleOrTypeVarTuple */) !== 0 &&
820
- (0, types_1.isInstantiableClass)(iterType) &&
821
- types_1.ClassType.isBuiltIn(iterType, 'tuple')) {
822
- typeResult = { type: types_1.ClassType.cloneForUnpacked(iterType) };
823
- }
824
- else {
825
- const iteratorTypeResult = (_a = getTypeOfIterator(iterTypeResult, /* isAsync */ false, node)) !== null && _a !== void 0 ? _a : {
826
- type: types_1.UnknownType.create(!!iterTypeResult.isIncomplete),
827
- isIncomplete: iterTypeResult.isIncomplete,
828
- };
829
- typeResult = {
830
- type: iteratorTypeResult.type,
831
- typeErrors: iterTypeResult.typeErrors,
832
- unpackedType: iterType,
833
- isIncomplete: iteratorTypeResult.isIncomplete,
834
- };
835
- }
835
+ const iteratorTypeResult = (_a = getTypeOfIterator(iterTypeResult, /* isAsync */ false, node)) !== null && _a !== void 0 ? _a : {
836
+ type: types_1.UnknownType.create(!!iterTypeResult.isIncomplete),
837
+ isIncomplete: iterTypeResult.isIncomplete,
838
+ };
839
+ typeResult = {
840
+ type: iteratorTypeResult.type,
841
+ typeErrors: iterTypeResult.typeErrors,
842
+ unpackedType: iterType,
843
+ isIncomplete: iteratorTypeResult.isIncomplete,
844
+ };
836
845
  }
837
846
  return typeResult;
838
847
  }
@@ -1491,8 +1500,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
1491
1500
  // type information than `__new__`.
1492
1501
  const initMethodResult = (0, constructors_1.getBoundInitMethod)(evaluatorInterface, callNode, types_1.ClassType.cloneAsInstance(subtype),
1493
1502
  /* skipObjectBase */ false);
1494
- if (initMethodResult && !initMethodResult.typeErrors && (0, types_1.isFunction)(initMethodResult.type)) {
1495
- constructorType = initMethodResult.type;
1503
+ if (initMethodResult && !initMethodResult.typeErrors) {
1504
+ if ((0, types_1.isFunction)(initMethodResult.type) || (0, types_1.isOverloadedFunction)(initMethodResult.type)) {
1505
+ constructorType = initMethodResult.type;
1506
+ }
1496
1507
  }
1497
1508
  const isObjectInit = constructorType &&
1498
1509
  (0, types_1.isFunction)(constructorType) &&
@@ -1506,11 +1517,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
1506
1517
  if (!constructorType || isObjectInit || isDefaultParams) {
1507
1518
  const newMethodResult = (0, constructors_1.getBoundNewMethod)(evaluatorInterface, callNode, subtype,
1508
1519
  /* skipObjectBase */ false);
1509
- if (newMethodResult &&
1510
- !newMethodResult.typeErrors &&
1511
- (0, types_1.isFunction)(newMethodResult.type) &&
1512
- newMethodResult.type.details.fullName !== 'builtins.object.__new__') {
1513
- constructorType = newMethodResult.type;
1520
+ if (newMethodResult && !newMethodResult.typeErrors && (0, types_1.isFunction)(newMethodResult.type)) {
1521
+ if ((0, types_1.isFunction)(newMethodResult.type) &&
1522
+ newMethodResult.type.details.fullName !== 'builtins.object.__new__') {
1523
+ constructorType = newMethodResult.type;
1524
+ }
1525
+ else if ((0, types_1.isOverloadedFunction)(newMethodResult.type)) {
1526
+ constructorType = newMethodResult.type;
1527
+ }
1514
1528
  }
1515
1529
  }
1516
1530
  if (constructorType) {
@@ -3282,7 +3296,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3282
3296
  name: type.typeAliasInfo.name,
3283
3297
  }), node);
3284
3298
  }
3285
- type = types_1.TypeBase.cloneForTypeAlias((0, typeUtils_1.applySolvedTypeVars)(type, typeVarContext, { unknownIfNotFound: true }), type.typeAliasInfo.name, type.typeAliasInfo.fullName, type.typeAliasInfo.typeVarScopeId, type.typeAliasInfo.isPep695Syntax, type.typeAliasInfo.typeParameters, defaultTypeArgs);
3299
+ type = types_1.TypeBase.cloneForTypeAlias((0, typeUtils_1.applySolvedTypeVars)(type, typeVarContext, { unknownIfNotFound: true }), type.typeAliasInfo.name, type.typeAliasInfo.fullName, type.typeAliasInfo.moduleName, type.typeAliasInfo.fileUri, type.typeAliasInfo.typeVarScopeId, type.typeAliasInfo.isPep695Syntax, type.typeAliasInfo.typeParameters, defaultTypeArgs);
3286
3300
  }
3287
3301
  return type;
3288
3302
  }
@@ -4634,7 +4648,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
4634
4648
  }
4635
4649
  aliasTypeArgs.push(typeVarType);
4636
4650
  });
4637
- const type = types_1.TypeBase.cloneForTypeAlias((0, typeUtils_1.applySolvedTypeVars)(baseType, typeVarContext), baseType.typeAliasInfo.name, baseType.typeAliasInfo.fullName, baseType.typeAliasInfo.typeVarScopeId, baseType.typeAliasInfo.isPep695Syntax, baseType.typeAliasInfo.typeParameters, aliasTypeArgs);
4651
+ const type = types_1.TypeBase.cloneForTypeAlias((0, typeUtils_1.applySolvedTypeVars)(baseType, typeVarContext), baseType.typeAliasInfo.name, baseType.typeAliasInfo.fullName, baseType.typeAliasInfo.moduleName, baseType.typeAliasInfo.fileUri, baseType.typeAliasInfo.typeVarScopeId, baseType.typeAliasInfo.isPep695Syntax, baseType.typeAliasInfo.typeParameters, aliasTypeArgs);
4638
4652
  return { type, node };
4639
4653
  }
4640
4654
  function getTypeOfIndexWithBaseType(node, baseTypeResult, usage, flags) {
@@ -4645,7 +4659,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
4645
4659
  }
4646
4660
  if ((0, types_1.isTypeVar)(baseTypeResult.type) && (0, typeUtils_1.isTypeAliasPlaceholder)(baseTypeResult.type)) {
4647
4661
  const typeArgTypes = getTypeArgs(node, flags).map((t) => (0, typeUtils_1.convertToInstance)(t.type));
4648
- const type = types_1.TypeBase.cloneForTypeAlias(baseTypeResult.type, baseTypeResult.type.details.recursiveTypeAliasName, '', baseTypeResult.type.details.recursiveTypeAliasScopeId, !!baseTypeResult.type.details.recursiveTypeAliasIsPep695Syntax, baseTypeResult.type.details.recursiveTypeParameters, typeArgTypes);
4662
+ const type = types_1.TypeBase.cloneForTypeAlias(baseTypeResult.type, baseTypeResult.type.details.recursiveTypeAliasName, '', '', uri_1.Uri.empty(), baseTypeResult.type.details.recursiveTypeAliasScopeId, !!baseTypeResult.type.details.recursiveTypeAliasIsPep695Syntax, baseTypeResult.type.details.recursiveTypeParameters, typeArgTypes);
4649
4663
  return { type };
4650
4664
  }
4651
4665
  let isIncomplete = baseTypeResult.isIncomplete;
@@ -6700,6 +6714,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
6700
6714
  const newClassType = types_1.ClassType.createInstantiable(newClassName, '', '', AnalyzerNodeInfo.getFileInfo(errorNode).fileUri, 0 /* ClassTypeFlags.None */, ParseTreeUtils.getTypeSourceId(errorNode), types_1.ClassType.cloneAsInstantiable(returnType), types_1.ClassType.cloneAsInstantiable(returnType));
6701
6715
  newClassType.details.baseClasses.push(getBuiltInType(errorNode, 'object'));
6702
6716
  newClassType.details.effectiveMetaclass = expandedCallType;
6717
+ newClassType.details.declaration = returnType.details.declaration;
6703
6718
  (0, typeUtils_1.computeMroLinearization)(newClassType);
6704
6719
  returnType = newClassType;
6705
6720
  }
@@ -6858,7 +6873,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
6858
6873
  }
6859
6874
  else if (typeResult.type.details.paramSpec) {
6860
6875
  const paramSpecScopeId = typeResult.type.details.paramSpec.scopeId;
6861
- if (paramSpecScopeId === typeResult.type.details.typeVarScopeId ||
6876
+ if (typeResult.type.details.typeVarScopeId === types_1.WildcardTypeVarScopeId ||
6877
+ paramSpecScopeId === typeResult.type.details.typeVarScopeId ||
6862
6878
  paramSpecScopeId === typeResult.type.details.constructorTypeVarScopeId) {
6863
6879
  hasParamSpecArgsKwargs = true;
6864
6880
  paramSpecArgList = [];
@@ -8136,7 +8152,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8136
8152
  let argErrorNode;
8137
8153
  for (const arg of argList) {
8138
8154
  const argType = (_a = getTypeOfArgument(arg)) === null || _a === void 0 ? void 0 : _a.type;
8139
- const isArgTypeCompatible = argType && ((0, types_1.isTypeSame)(argType, paramSpec) || (0, types_1.isAnyOrUnknown)(argType));
8155
+ const isArgTypeCompatible = argType && ((0, types_1.isTypeSame)(argType, paramSpec, { ignoreTypeFlags: true }) || (0, types_1.isAnyOrUnknown)(argType));
8140
8156
  if (arg.argumentCategory === 1 /* ArgumentCategory.UnpackedList */ && !sawArgs && isArgTypeCompatible) {
8141
8157
  sawArgs = true;
8142
8158
  }
@@ -10745,7 +10761,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
10745
10761
  }
10746
10762
  }
10747
10763
  const fileInfo = AnalyzerNodeInfo.getFileInfo(name);
10748
- const typeAlias = types_1.TypeBase.cloneForTypeAlias(type, name.value, ParseTreeUtils.getClassFullName(name, fileInfo.moduleName, name.value), typeAliasScopeId, isPep695Syntax, typeParameters.length > 0 ? typeParameters : undefined);
10764
+ const typeAlias = types_1.TypeBase.cloneForTypeAlias(type, name.value, ParseTreeUtils.getClassFullName(name, fileInfo.moduleName, name.value), fileInfo.moduleName, fileInfo.fileUri, typeAliasScopeId, isPep695Syntax, typeParameters.length > 0 ? typeParameters : undefined);
10749
10765
  // All PEP 695 type aliases are special forms because they are
10750
10766
  // TypeAliasType objects at runtime.
10751
10767
  if (isPep695Syntax || isPep695TypeVarType) {
@@ -10754,11 +10770,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
10754
10770
  return typeAlias;
10755
10771
  }
10756
10772
  function createSpecialBuiltInClass(node, assignedName, aliasMapEntry) {
10773
+ var _a;
10757
10774
  const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
10758
10775
  let specialClassType = types_1.ClassType.createInstantiable(assignedName, ParseTreeUtils.getClassFullName(node, fileInfo.moduleName, assignedName), fileInfo.moduleName, fileInfo.fileUri, 1 /* ClassTypeFlags.BuiltInClass */ | 2 /* ClassTypeFlags.SpecialBuiltIn */,
10759
10776
  /* typeSourceId */ 0,
10760
10777
  /* declaredMetaclass */ undefined,
10761
10778
  /* effectiveMetaclass */ undefined);
10779
+ const specialBuiltInClassDeclaration = ((_a = AnalyzerNodeInfo.getDeclaration(node)) !== null && _a !== void 0 ? _a : (node.parent ? AnalyzerNodeInfo.getDeclaration(node.parent) : undefined));
10780
+ specialClassType.details.declaration = specialBuiltInClassDeclaration;
10762
10781
  if (fileInfo.isTypingExtensionsStubFile) {
10763
10782
  specialClassType.details.flags |= 65536 /* ClassTypeFlags.TypingExtensionClass */;
10764
10783
  }
@@ -11188,6 +11207,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11188
11207
  setSymbolResolutionPartialType(classSymbol, classDecl, classType);
11189
11208
  }
11190
11209
  classType.details.flags |= 131072 /* ClassTypeFlags.PartiallyEvaluated */;
11210
+ classType.details.declaration = classDecl;
11191
11211
  try {
11192
11212
  writeTypeCache(node, { type: classType }, /* flags */ undefined);
11193
11213
  writeTypeCache(node.name, { type: classType }, /* flags */ undefined);
@@ -12785,7 +12805,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
12785
12805
  // This eliminates any "partially unknown" errors in strict mode
12786
12806
  // in the common case.
12787
12807
  const sendType = isYieldResultUsed ? types_1.UnknownType.create() : types_1.AnyType.create();
12788
- typeArgs.push(inferredYieldType, sendType, (0, types_1.isNever)(inferredReturnType) ? getNoneType() : inferredReturnType);
12808
+ typeArgs.push(inferredYieldType, sendType, inferredReturnType);
12789
12809
  if (useAwaitableGenerator) {
12790
12810
  typeArgs.push(types_1.AnyType.create());
12791
12811
  }
@@ -15343,7 +15363,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15343
15363
  var _a;
15344
15364
  let returnType;
15345
15365
  let isIncomplete = false;
15346
- let analyzeUnannotatedFunctions = true;
15366
+ const analyzeUnannotatedFunctions = true;
15347
15367
  // Don't attempt to infer the return type for a stub file.
15348
15368
  if (types_1.FunctionType.isStubDefinition(type)) {
15349
15369
  return types_1.UnknownType.create();
@@ -15366,10 +15386,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15366
15386
  }
15367
15387
  else if (type.details.declaration) {
15368
15388
  const functionNode = type.details.declaration.node;
15369
- analyzeUnannotatedFunctions =
15370
- AnalyzerNodeInfo.getFileInfo(functionNode).diagnosticRuleSet.analyzeUnannotatedFunctions;
15389
+ const skipUnannotatedFunction = !AnalyzerNodeInfo.getFileInfo(functionNode).diagnosticRuleSet.analyzeUnannotatedFunctions &&
15390
+ ParseTreeUtils.isUnannotatedFunction(functionNode);
15371
15391
  // Skip return type inference if we are in "skip unannotated function" mode.
15372
- if (analyzeUnannotatedFunctions && !checkCodeFlowTooComplex(functionNode.suite)) {
15392
+ if (!skipUnannotatedFunction && !checkCodeFlowTooComplex(functionNode.suite)) {
15373
15393
  const codeFlowComplexity = AnalyzerNodeInfo.getCodeFlowComplexity(functionNode);
15374
15394
  // For very complex functions that have no annotated parameter types,
15375
15395
  // don't attempt to infer the return type because it can be extremely
@@ -16691,7 +16711,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16691
16711
  let canUseFastPath = true;
16692
16712
  // First attempt to match all of the non-generic types in the dest
16693
16713
  // to non-generic types in the source.
16694
- destType.subtypes.forEach((destSubtype) => {
16714
+ (0, typeUtils_1.sortTypes)(destType.subtypes).forEach((destSubtype) => {
16695
16715
  if ((0, typeUtils_1.requiresSpecialization)(destSubtype)) {
16696
16716
  remainingDestSubtypes.push(destSubtype);
16697
16717
  }
@@ -17199,7 +17219,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17199
17219
  }
17200
17220
  }
17201
17221
  function assignFunction(destType, srcType, diag, destTypeVarContext, srcTypeVarContext, flags, recursionCount) {
17202
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
17222
+ var _a, _b, _c, _d, _e, _f, _g, _h;
17203
17223
  let canAssign = true;
17204
17224
  const checkReturnType = (flags & 32 /* AssignTypeFlags.SkipFunctionReturnTypeCheck */) === 0;
17205
17225
  const reverseMatching = (flags & 2 /* AssignTypeFlags.ReverseTypeVarMatching */) !== 0;
@@ -17210,19 +17230,23 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17210
17230
  const srcParamDetails = (0, parameterUtils_1.getParameterListDetails)(srcType);
17211
17231
  adjustSourceParamDetailsForDestVariadic(reverseMatching ? destParamDetails : srcParamDetails, reverseMatching ? srcParamDetails : destParamDetails);
17212
17232
  const targetIncludesParamSpec = reverseMatching ? !!srcType.details.paramSpec : !!destType.details.paramSpec;
17213
- const destPositionalCount = (_b = (_a = destParamDetails.argsIndex) !== null && _a !== void 0 ? _a : destParamDetails.firstKeywordOnlyIndex) !== null && _b !== void 0 ? _b : destParamDetails.params.length;
17214
- const srcPositionalCount = (_d = (_c = srcParamDetails.argsIndex) !== null && _c !== void 0 ? _c : srcParamDetails.firstKeywordOnlyIndex) !== null && _d !== void 0 ? _d : srcParamDetails.params.length;
17233
+ const destPositionalCount = (_a = destParamDetails.firstKeywordOnlyIndex) !== null && _a !== void 0 ? _a : destParamDetails.params.length;
17234
+ const srcPositionalCount = (_b = srcParamDetails.firstKeywordOnlyIndex) !== null && _b !== void 0 ? _b : srcParamDetails.params.length;
17215
17235
  const positionalsToMatch = Math.min(destPositionalCount, srcPositionalCount);
17216
17236
  // Match positional parameters.
17217
17237
  for (let paramIndex = 0; paramIndex < positionalsToMatch; paramIndex++) {
17238
+ // Skip over the *args parameter since it's handled separately below.
17239
+ if (paramIndex === destParamDetails.argsIndex) {
17240
+ continue;
17241
+ }
17218
17242
  const destParam = destParamDetails.params[paramIndex];
17219
17243
  const srcParam = srcParamDetails.params[paramIndex];
17220
17244
  // Find the original index of this source param. If we synthesized it above (for
17221
17245
  // a variadic parameter), it may not be found.
17222
17246
  const srcParamType = srcParam.type;
17223
17247
  const destParamType = destParam.type;
17224
- const destParamName = (_e = destParam.param.name) !== null && _e !== void 0 ? _e : '';
17225
- const srcParamName = (_f = srcParam.param.name) !== null && _f !== void 0 ? _f : '';
17248
+ const destParamName = (_c = destParam.param.name) !== null && _c !== void 0 ? _c : '';
17249
+ const srcParamName = (_d = srcParam.param.name) !== null && _d !== void 0 ? _d : '';
17226
17250
  if (destParamName && !(0, symbolNameUtils_1.isPrivateOrProtectedName)(destParamName) && !(0, symbolNameUtils_1.isPrivateOrProtectedName)(srcParamName)) {
17227
17251
  const isDestPositionalOnly = destParam.source === parameterUtils_1.ParameterSource.PositionOnly;
17228
17252
  if (!isDestPositionalOnly &&
@@ -17236,7 +17260,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17236
17260
  canAssign = false;
17237
17261
  }
17238
17262
  }
17239
- if (!!destParam.param.hasDefault && !srcParam.param.hasDefault) {
17263
+ if (!!destParam.param.hasDefault &&
17264
+ !srcParam.param.hasDefault &&
17265
+ paramIndex !== srcParamDetails.argsIndex) {
17240
17266
  diag === null || diag === void 0 ? void 0 : diag.createAddendum().addMessage(localize_1.Localizer.DiagnosticAddendum.functionParamDefaultMissing().format({
17241
17267
  name: srcParamName,
17242
17268
  }));
@@ -17310,6 +17336,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17310
17336
  // *args parameter type.
17311
17337
  const srcArgsType = srcParamDetails.params[srcParamDetails.argsIndex].type;
17312
17338
  for (let paramIndex = srcPositionalCount; paramIndex < destPositionalCount; paramIndex++) {
17339
+ if (paramIndex === srcParamDetails.argsIndex) {
17340
+ continue;
17341
+ }
17313
17342
  const destParamType = destParamDetails.params[paramIndex].type;
17314
17343
  if ((0, types_1.isVariadicTypeVar)(destParamType) && !(0, types_1.isVariadicTypeVar)(srcArgsType)) {
17315
17344
  diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.typeVarTupleRequiresKnownLength());
@@ -17322,7 +17351,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17322
17351
  if (destParamDetails.params[paramIndex].source !== parameterUtils_1.ParameterSource.PositionOnly &&
17323
17352
  srcParamDetails.kwargsIndex === undefined) {
17324
17353
  diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.namedParamMissingInSource().format({
17325
- name: (_g = destParamDetails.params[paramIndex].param.name) !== null && _g !== void 0 ? _g : '',
17354
+ name: (_e = destParamDetails.params[paramIndex].param.name) !== null && _e !== void 0 ? _e : '',
17326
17355
  }));
17327
17356
  canAssign = false;
17328
17357
  }
@@ -17330,11 +17359,19 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17330
17359
  }
17331
17360
  }
17332
17361
  else if (!srcParamDetails.paramSpec) {
17333
- diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.functionTooManyParams().format({
17334
- expected: srcPositionalCount,
17335
- received: destPositionalCount,
17336
- }));
17337
- canAssign = false;
17362
+ // If the dest contains a *args, remove it from the positional count
17363
+ // because it's OK for zero source args to match it.
17364
+ let adjDestPositionalCount = destPositionalCount;
17365
+ if (destParamDetails.argsIndex !== undefined && destParamDetails.argsIndex < destPositionalCount) {
17366
+ adjDestPositionalCount--;
17367
+ }
17368
+ if (srcPositionalCount < adjDestPositionalCount) {
17369
+ diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.functionTooManyParams().format({
17370
+ expected: srcPositionalCount,
17371
+ received: destPositionalCount,
17372
+ }));
17373
+ canAssign = false;
17374
+ }
17338
17375
  }
17339
17376
  }
17340
17377
  // If both src and dest have an "*args" parameter, make sure
@@ -17366,7 +17403,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17366
17403
  destParamDetails.argsIndex !== undefined &&
17367
17404
  !destParamDetails.hasUnpackedVariadicTypeVar) {
17368
17405
  diag === null || diag === void 0 ? void 0 : diag.createAddendum().addMessage(localize_1.Localizer.DiagnosticAddendum.argsParamMissing().format({
17369
- paramName: (_h = destParamDetails.params[destParamDetails.argsIndex].param.name) !== null && _h !== void 0 ? _h : '',
17406
+ paramName: (_f = destParamDetails.params[destParamDetails.argsIndex].param.name) !== null && _f !== void 0 ? _f : '',
17370
17407
  }));
17371
17408
  canAssign = false;
17372
17409
  }
@@ -17477,7 +17514,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17477
17514
  // If the source and the dest are using the same ParamSpec, any additional
17478
17515
  // concatenated parameters must match.
17479
17516
  if (targetIncludesParamSpec &&
17480
- ((_j = srcType.details.paramSpec) === null || _j === void 0 ? void 0 : _j.nameWithScope) === ((_k = destType.details.paramSpec) === null || _k === void 0 ? void 0 : _k.nameWithScope)) {
17517
+ ((_g = srcType.details.paramSpec) === null || _g === void 0 ? void 0 : _g.nameWithScope) === ((_h = destType.details.paramSpec) === null || _h === void 0 ? void 0 : _h.nameWithScope)) {
17481
17518
  if (srcParamDetails.params.length !== destParamDetails.params.length) {
17482
17519
  canAssign = false;
17483
17520
  }