@zzzen/pyright-internal 1.2.0-dev.20240616 → 1.2.0-dev.20240630

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 (110) hide show
  1. package/dist/analyzer/cacheManager.js +3 -0
  2. package/dist/analyzer/cacheManager.js.map +1 -1
  3. package/dist/analyzer/checker.d.ts +3 -0
  4. package/dist/analyzer/checker.js +242 -153
  5. package/dist/analyzer/checker.js.map +1 -1
  6. package/dist/analyzer/codeFlowEngine.d.ts +1 -1
  7. package/dist/analyzer/codeFlowEngine.js +7 -12
  8. package/dist/analyzer/codeFlowEngine.js.map +1 -1
  9. package/dist/analyzer/constructors.js +28 -3
  10. package/dist/analyzer/constructors.js.map +1 -1
  11. package/dist/analyzer/dataClasses.d.ts +2 -1
  12. package/dist/analyzer/dataClasses.js +5 -2
  13. package/dist/analyzer/dataClasses.js.map +1 -1
  14. package/dist/analyzer/importResolver.d.ts +4 -8
  15. package/dist/analyzer/importResolver.js +87 -85
  16. package/dist/analyzer/importResolver.js.map +1 -1
  17. package/dist/analyzer/parseTreeUtils.js +18 -2
  18. package/dist/analyzer/parseTreeUtils.js.map +1 -1
  19. package/dist/analyzer/patternMatching.js +22 -5
  20. package/dist/analyzer/patternMatching.js.map +1 -1
  21. package/dist/analyzer/service.js +1 -1
  22. package/dist/analyzer/service.js.map +1 -1
  23. package/dist/analyzer/typeEvaluator.js +202 -215
  24. package/dist/analyzer/typeEvaluator.js.map +1 -1
  25. package/dist/analyzer/typeEvaluatorTypes.d.ts +0 -1
  26. package/dist/analyzer/typeGuards.js +42 -14
  27. package/dist/analyzer/typeGuards.js.map +1 -1
  28. package/dist/analyzer/typeUtils.js +19 -9
  29. package/dist/analyzer/typeUtils.js.map +1 -1
  30. package/dist/analyzer/types.js +11 -7
  31. package/dist/analyzer/types.js.map +1 -1
  32. package/dist/backgroundAnalysis.js +3 -1
  33. package/dist/backgroundAnalysis.js.map +1 -1
  34. package/dist/backgroundAnalysisBase.js +1 -1
  35. package/dist/backgroundAnalysisBase.js.map +1 -1
  36. package/dist/backgroundThreadBase.d.ts +2 -2
  37. package/dist/common/collectionUtils.d.ts +2 -2
  38. package/dist/common/collectionUtils.js.map +1 -1
  39. package/dist/common/core.d.ts +8 -3
  40. package/dist/common/core.js.map +1 -1
  41. package/dist/common/diagnostic.d.ts +1 -0
  42. package/dist/common/diagnostic.js +5 -0
  43. package/dist/common/diagnostic.js.map +1 -1
  44. package/dist/common/docStringService.d.ts +2 -1
  45. package/dist/common/docStringService.js.map +1 -1
  46. package/dist/common/envVarUtils.js.map +1 -1
  47. package/dist/common/textRangeCollection.d.ts +1 -1
  48. package/dist/common/textRangeCollection.js +14 -14
  49. package/dist/common/textRangeCollection.js.map +1 -1
  50. package/dist/languageServerBase.js +20 -16
  51. package/dist/languageServerBase.js.map +1 -1
  52. package/dist/languageService/autoImporter.d.ts +7 -4
  53. package/dist/languageService/autoImporter.js +15 -12
  54. package/dist/languageService/autoImporter.js.map +1 -1
  55. package/dist/languageService/completionProvider.d.ts +1 -0
  56. package/dist/languageService/completionProvider.js +22 -17
  57. package/dist/languageService/completionProvider.js.map +1 -1
  58. package/dist/languageService/hoverProvider.d.ts +1 -1
  59. package/dist/languageService/hoverProvider.js +11 -7
  60. package/dist/languageService/hoverProvider.js.map +1 -1
  61. package/dist/languageService/signatureHelpProvider.js +19 -2
  62. package/dist/languageService/signatureHelpProvider.js.map +1 -1
  63. package/dist/localization/localize.d.ts +2 -1
  64. package/dist/localization/localize.js +3 -2
  65. package/dist/localization/localize.js.map +1 -1
  66. package/dist/localization/package.nls.cs.json +4 -1
  67. package/dist/localization/package.nls.de.json +3 -0
  68. package/dist/localization/package.nls.en-us.json +1 -0
  69. package/dist/localization/package.nls.es.json +3 -0
  70. package/dist/localization/package.nls.fr.json +3 -0
  71. package/dist/localization/package.nls.it.json +3 -0
  72. package/dist/localization/package.nls.ja.json +3 -0
  73. package/dist/localization/package.nls.ko.json +3 -0
  74. package/dist/localization/package.nls.pl.json +3 -0
  75. package/dist/localization/package.nls.pt-br.json +4 -1
  76. package/dist/localization/package.nls.qps-ploc.json +3 -0
  77. package/dist/localization/package.nls.ru.json +3 -0
  78. package/dist/localization/package.nls.tr.json +3 -0
  79. package/dist/localization/package.nls.zh-cn.json +3 -0
  80. package/dist/localization/package.nls.zh-tw.json +3 -0
  81. package/dist/parser/parseNodes.d.ts +3 -1
  82. package/dist/parser/parseNodes.js +3 -1
  83. package/dist/parser/parseNodes.js.map +1 -1
  84. package/dist/parser/parser.js +14 -6
  85. package/dist/parser/parser.js.map +1 -1
  86. package/dist/tests/checker.test.js +2 -2
  87. package/dist/tests/completions.test.js +80 -0
  88. package/dist/tests/completions.test.js.map +1 -1
  89. package/dist/tests/fourslash/hover.docstring.alias.fourslash.js +5 -5
  90. package/dist/tests/fourslash/hover.docstring.alias.fourslash.js.map +1 -1
  91. package/dist/tests/fourslash/hover.init.fourslash.js +1 -1
  92. package/dist/tests/fourslash/hover.init.fourslash.js.map +1 -1
  93. package/dist/tests/fourslash/hover.variable.docString.fourslash.js +1 -1
  94. package/dist/tests/fourslash/hover.variable.docString.fourslash.js.map +1 -1
  95. package/dist/tests/languageServer.test.js +39 -4
  96. package/dist/tests/languageServer.test.js.map +1 -1
  97. package/dist/tests/lsp/languageServer.js +19 -3
  98. package/dist/tests/lsp/languageServer.js.map +1 -1
  99. package/dist/tests/parseTreeUtils.test.js +89 -0
  100. package/dist/tests/parseTreeUtils.test.js.map +1 -1
  101. package/dist/tests/typeEvaluator1.test.js +1 -1
  102. package/dist/tests/typeEvaluator2.test.js +4 -0
  103. package/dist/tests/typeEvaluator2.test.js.map +1 -1
  104. package/dist/tests/typeEvaluator3.test.js +5 -1
  105. package/dist/tests/typeEvaluator3.test.js.map +1 -1
  106. package/dist/tests/typeEvaluator6.test.js +4 -0
  107. package/dist/tests/typeEvaluator6.test.js.map +1 -1
  108. package/dist/tests/typeEvaluator7.test.js +1 -1
  109. package/dist/tests/typeEvaluator8.test.js +1 -1
  110. package/package.json +4 -4
@@ -2143,15 +2143,38 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
2143
2143
  }
2144
2144
  }
2145
2145
  function addDiagnosticWithSuppressionCheck(diagLevel, message, node, range) {
2146
- if (!isDiagnosticSuppressedForNode(node) && isNodeReachable(node)) {
2146
+ var _a;
2147
+ if (isDiagnosticSuppressedForNode(node)) {
2148
+ // See if this node is suppressed but the diagnostic should be generated
2149
+ // anyway so it can be used by the caller that requested the suppression.
2150
+ const suppressionEntry = suppressedNodeStack.find((suppressedNode) => ParseTreeUtils.isNodeContainedWithin(node, suppressedNode.node) && suppressedNode.suppressedDiags);
2151
+ (_a = suppressionEntry === null || suppressionEntry === void 0 ? void 0 : suppressionEntry.suppressedDiags) === null || _a === void 0 ? void 0 : _a.push(message);
2152
+ return undefined;
2153
+ }
2154
+ if (isNodeReachable(node)) {
2147
2155
  const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
2148
- return fileInfo.diagnosticSink.addDiagnosticWithTextRange(diagLevel, message, range || node);
2156
+ return fileInfo.diagnosticSink.addDiagnosticWithTextRange(diagLevel, message, range !== null && range !== void 0 ? range : node);
2149
2157
  }
2150
2158
  return undefined;
2151
2159
  }
2152
2160
  function isDiagnosticSuppressedForNode(node) {
2153
- return (suppressedNodeStack.some((suppressedNode) => ParseTreeUtils.isNodeContainedWithin(node, suppressedNode)) ||
2154
- speculativeTypeTracker.isSpeculative(node, /* ignoreIfDiagnosticsAllowed */ true));
2161
+ if (speculativeTypeTracker.isSpeculative(node, /* ignoreIfDiagnosticsAllowed */ true)) {
2162
+ return true;
2163
+ }
2164
+ return suppressedNodeStack.some((suppressedNode) => ParseTreeUtils.isNodeContainedWithin(node, suppressedNode.node));
2165
+ }
2166
+ // This function is similar to isDiagnosticSuppressedForNode except that it
2167
+ // returns false if diagnostics are suppressed for the node but the caller
2168
+ // has requested that diagnostics be generated anyway.
2169
+ function canSkipDiagnosticForNode(node) {
2170
+ if (speculativeTypeTracker.isSpeculative(node, /* ignoreIfDiagnosticsAllowed */ true)) {
2171
+ return true;
2172
+ }
2173
+ const suppressedEntries = suppressedNodeStack.filter((suppressedNode) => ParseTreeUtils.isNodeContainedWithin(node, suppressedNode.node));
2174
+ if (suppressedEntries.length === 0) {
2175
+ return false;
2176
+ }
2177
+ return suppressedEntries.every((entry) => !entry.suppressedDiags);
2155
2178
  }
2156
2179
  function addDiagnostic(rule, message, node, range) {
2157
2180
  const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
@@ -4230,6 +4253,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
4230
4253
  /* skipUnknownArgCheck */ true,
4231
4254
  /* inferenceContext */ undefined,
4232
4255
  /* signatureTracker */ undefined);
4256
+ }, (suppressedDiags) => {
4257
+ // If diagnostics were recorded when suppressed, add them to the
4258
+ // diagnostic as messages.
4259
+ if (diag) {
4260
+ suppressedDiags.forEach((message) => {
4261
+ diag === null || diag === void 0 ? void 0 : diag.addMessageMultiline(message);
4262
+ });
4263
+ }
4233
4264
  });
4234
4265
  // Collect deprecation information associated with the member access method.
4235
4266
  let deprecationInfo;
@@ -4252,28 +4283,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
4252
4283
  memberAccessDeprecationInfo: deprecationInfo,
4253
4284
  };
4254
4285
  }
4255
- // Errors were detected when evaluating the access method call.
4256
- if (usage.method === 'set') {
4257
- if (usage.setType &&
4258
- (0, types_1.isFunction)(methodType) &&
4259
- methodType.details.parameters.length >= 2 &&
4260
- !usage.setType.isIncomplete) {
4261
- const setterType = types_1.FunctionType.getEffectiveParameterType(methodType, 1);
4262
- diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocAddendum.typeIncompatible().format({
4263
- destType: printType(setterType),
4264
- sourceType: printType(usage.setType.type),
4265
- }));
4266
- }
4267
- else if ((0, types_1.isOverloadedFunction)(methodType)) {
4268
- diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocMessage.noOverload().format({ name: accessMethodName }));
4269
- }
4270
- }
4271
- else {
4272
- diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocAddendum.descriptorAccessCallFailed().format({
4273
- name: accessMethodName,
4274
- className: printType((0, typeUtils_1.convertToInstance)(methodClassType)),
4275
- }));
4276
- }
4277
4286
  return {
4278
4287
  type: types_1.UnknownType.create(),
4279
4288
  typeErrors: true,
@@ -5179,7 +5188,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
5179
5188
  });
5180
5189
  positionalIndexType = makeTupleObject(tupleTypeArgs);
5181
5190
  }
5182
- let argList = [
5191
+ const argList = [
5183
5192
  {
5184
5193
  argumentCategory: 0 /* ArgumentCategory.Simple */,
5185
5194
  typeResult: { type: positionalIndexType, isIncomplete: isPositionalIndexTypeIncomplete },
@@ -5216,44 +5225,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
5216
5225
  node: arg,
5217
5226
  });
5218
5227
  });
5219
- let callResult;
5220
- // Speculatively attempt the call. We may need to replace the index
5221
- // type with 'int', and we don't want to emit errors before we know
5222
- // which type to use.
5223
- if (keywordArgs.length === 0 && unpackedDictArgs.length === 0 && positionalArgs.length === 1) {
5224
- useSpeculativeMode(node, () => {
5225
- callResult = validateCallArguments(node, argList, { type: itemMethodType },
5226
- /* typeVarContext */ undefined,
5227
- /* skipUnknownArgCheck */ true,
5228
- /* inferenceContext */ undefined,
5229
- /* signatureTracker */ undefined);
5230
- if (callResult.argumentErrors) {
5231
- // If the object supports "__index__" magic method, convert
5232
- // the index to an int and try again.
5233
- if ((0, types_1.isClassInstance)(positionalIndexType)) {
5234
- const altArgList = [...argList];
5235
- altArgList[0] = { ...altArgList[0] };
5236
- const indexMethod = getBoundMagicMethod(positionalIndexType, '__index__');
5237
- if (indexMethod) {
5238
- const intType = getBuiltInObject(node, 'int');
5239
- if ((0, types_1.isClassInstance)(intType)) {
5240
- altArgList[0].typeResult = { type: intType };
5241
- }
5242
- }
5243
- callResult = validateCallArguments(node, altArgList, { type: itemMethodType },
5244
- /* typeVarContext */ undefined,
5245
- /* skipUnknownArgCheck */ true,
5246
- /* inferenceContext */ undefined,
5247
- /* signatureTracker */ undefined);
5248
- // We were successful, so replace the arg list.
5249
- if (!callResult.argumentErrors) {
5250
- argList = altArgList;
5251
- }
5252
- }
5253
- }
5254
- });
5255
- }
5256
- callResult = validateCallArguments(node, argList, { type: itemMethodType },
5228
+ const callResult = validateCallArguments(node, argList, { type: itemMethodType },
5257
5229
  /* typeVarContext */ undefined,
5258
5230
  /* skipUnknownArgCheck */ true,
5259
5231
  /* inferenceContext */ undefined,
@@ -6398,7 +6370,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
6398
6370
  if (filteredMatchResults.length === 0) {
6399
6371
  // Skip the error message if we're in speculative mode because it's very
6400
6372
  // expensive, and we're going to suppress the diagnostic anyway.
6401
- if (!isDiagnosticSuppressedForNode(errorNode)) {
6373
+ if (!canSkipDiagnosticForNode(errorNode)) {
6402
6374
  const functionName = typeResult.type.overloads[0].details.name || '<anonymous function>';
6403
6375
  const diagAddendum = new diagnostic_1.DiagnosticAddendum();
6404
6376
  const argTypes = argList.map((t) => {
@@ -6490,7 +6462,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
6490
6462
  // We couldn't find any valid overloads. Skip the error message if we're
6491
6463
  // in speculative mode because it's very expensive, and we're going to
6492
6464
  // suppress the diagnostic anyway.
6493
- if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
6465
+ if (!canSkipDiagnosticForNode(errorNode) && !isTypeIncomplete) {
6494
6466
  const result = evaluateUsingBestMatchingOverload(
6495
6467
  /* skipUnknownArgCheck */ true,
6496
6468
  /* emitNoOverloadFoundError */ true);
@@ -7250,7 +7222,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
7250
7222
  tooManyPositionals = true;
7251
7223
  }
7252
7224
  if (tooManyPositionals) {
7253
- if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7225
+ if (!canSkipDiagnosticForNode(errorNode) && !isTypeIncomplete) {
7254
7226
  addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, positionParamLimitIndex === 1
7255
7227
  ? localize_1.LocMessage.argPositionalExpectedOne()
7256
7228
  : localize_1.LocMessage.argPositionalExpectedCount().format({
@@ -7284,7 +7256,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
7284
7256
  if ((0, types_1.isTypeVar)(argTypeResult.type) &&
7285
7257
  argTypeResult.type.paramSpecAccess === 'args' &&
7286
7258
  paramDetails.params[paramIndex].param.category !== 1 /* ParameterCategory.ArgsList */) {
7287
- if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7259
+ if (!canSkipDiagnosticForNode(errorNode) && !isTypeIncomplete) {
7288
7260
  addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, positionParamLimitIndex === 1
7289
7261
  ? localize_1.LocMessage.argPositionalExpectedOne()
7290
7262
  : localize_1.LocMessage.argPositionalExpectedCount().format({
@@ -7350,7 +7322,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
7350
7322
  // It's not allowed to use unpacked arguments with a variadic *args
7351
7323
  // parameter unless the argument is a variadic arg as well.
7352
7324
  if (isParamVariadic && !isArgCompatibleWithVariadic) {
7353
- if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7325
+ if (!canSkipDiagnosticForNode(errorNode) && !isTypeIncomplete) {
7354
7326
  addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.unpackedArgWithVariadicParam(), argList[argIndex].valueExpression || errorNode);
7355
7327
  }
7356
7328
  reportedArgError = true;
@@ -7407,7 +7379,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
7407
7379
  : 0 /* ParameterCategory.Simple */;
7408
7380
  if (remainingArgCount <= remainingParamCount) {
7409
7381
  if (remainingArgCount < remainingParamCount) {
7410
- if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7382
+ if (!canSkipDiagnosticForNode(errorNode) && !isTypeIncomplete) {
7411
7383
  // Have we run out of arguments and still have parameters left to fill?
7412
7384
  addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, remainingArgCount === 1
7413
7385
  ? localize_1.LocMessage.argMorePositionalExpectedOne()
@@ -7490,7 +7462,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
7490
7462
  argsRemainingCount--;
7491
7463
  }
7492
7464
  if (argsRemainingCount > 0) {
7493
- if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7465
+ if (!canSkipDiagnosticForNode(errorNode) && !isTypeIncomplete) {
7494
7466
  addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, argsRemainingCount === 1
7495
7467
  ? localize_1.LocMessage.argMorePositionalExpectedOne()
7496
7468
  : localize_1.LocMessage.argMorePositionalExpectedCount().format({
@@ -7508,7 +7480,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
7508
7480
  while (argIndex < argList.length) {
7509
7481
  if (argList[argIndex].argumentCategory === 2 /* ArgumentCategory.UnpackedDictionary */) {
7510
7482
  // Verify that the type used in this expression is a SupportsKeysAndGetItem[str, T].
7511
- const argType = getTypeOfArgument(argList[argIndex], (0, typeUtils_1.makeInferenceContext)(paramDetails.unpackedKwargsTypedDictType), signatureTracker).type;
7483
+ const argTypeResult = getTypeOfArgument(argList[argIndex], (0, typeUtils_1.makeInferenceContext)(paramDetails.unpackedKwargsTypedDictType), signatureTracker);
7484
+ const argType = argTypeResult.type;
7485
+ if (argTypeResult.isIncomplete) {
7486
+ isTypeIncomplete = true;
7487
+ }
7512
7488
  if ((0, types_1.isAnyOrUnknown)(argType)) {
7513
7489
  unpackedDictionaryArgType = argType;
7514
7490
  }
@@ -7572,7 +7548,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
7572
7548
  }
7573
7549
  });
7574
7550
  if (!diag.isEmpty()) {
7575
- if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7551
+ if (!canSkipDiagnosticForNode(errorNode) && !isTypeIncomplete) {
7576
7552
  addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.unpackedTypedDictArgument() + diag.getString(), argList[argIndex].valueExpression || errorNode);
7577
7553
  }
7578
7554
  reportedArgError = true;
@@ -7632,7 +7608,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
7632
7608
  });
7633
7609
  }
7634
7610
  if (!isValidMappingType) {
7635
- if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7611
+ if (!canSkipDiagnosticForNode(errorNode) && !isTypeIncomplete) {
7636
7612
  addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.unpackedDictArgumentNotMapping(), argList[argIndex].valueExpression || errorNode);
7637
7613
  }
7638
7614
  reportedArgError = true;
@@ -7653,7 +7629,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
7653
7629
  const paramEntry = paramMap.get(paramNameValue);
7654
7630
  if (paramEntry && !paramEntry.isPositionalOnly) {
7655
7631
  if (paramEntry.argsReceived > 0) {
7656
- if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7632
+ if (!canSkipDiagnosticForNode(errorNode) && !isTypeIncomplete) {
7657
7633
  addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.paramAlreadyAssigned().format({ name: paramNameValue }), paramName);
7658
7634
  }
7659
7635
  reportedArgError = true;
@@ -7697,7 +7673,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
7697
7673
  trySetActive(argList[argIndex], paramDetails.params[paramDetails.kwargsIndex].param);
7698
7674
  }
7699
7675
  else {
7700
- if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7676
+ if (!canSkipDiagnosticForNode(errorNode) && !isTypeIncomplete) {
7701
7677
  addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.paramNameMissing().format({ name: paramName.value }), paramName);
7702
7678
  }
7703
7679
  reportedArgError = true;
@@ -7708,7 +7684,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
7708
7684
  paramSpecArgList.push(argList[argIndex]);
7709
7685
  }
7710
7686
  else {
7711
- if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7687
+ if (!canSkipDiagnosticForNode(errorNode) && !isTypeIncomplete) {
7712
7688
  addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, positionParamLimitIndex === 1
7713
7689
  ? localize_1.LocMessage.argPositionalExpectedOne()
7714
7690
  : localize_1.LocMessage.argPositionalExpectedCount().format({
@@ -7784,9 +7760,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
7784
7760
  return !entry || entry.argsReceived < entry.argsNeeded;
7785
7761
  });
7786
7762
  if (unassignedParams.length > 0) {
7787
- if (!isDiagnosticSuppressedForNode(errorNode)) {
7763
+ if (!canSkipDiagnosticForNode(errorNode)) {
7788
7764
  const missingParamNames = unassignedParams.map((p) => `"${p}"`).join(', ');
7789
- if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7765
+ if (!canSkipDiagnosticForNode(errorNode) && !isTypeIncomplete) {
7790
7766
  addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, unassignedParams.length === 1
7791
7767
  ? localize_1.LocMessage.argMissingForParam().format({ name: missingParamNames })
7792
7768
  : localize_1.LocMessage.argMissingForParams().format({ names: missingParamNames }), errorNode);
@@ -7857,7 +7833,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
7857
7833
  if (containsVariadicTypeVar &&
7858
7834
  argParam.argument.argumentCategory !== 1 /* ArgumentCategory.UnpackedList */ &&
7859
7835
  !argParam.mapsToVarArgList) {
7860
- if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7836
+ if (!canSkipDiagnosticForNode(errorNode) && !isTypeIncomplete) {
7861
7837
  addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.typeVarTupleMustBeUnpacked(), (_a = argParam.argument.valueExpression) !== null && _a !== void 0 ? _a : errorNode);
7862
7838
  }
7863
7839
  reportedArgError = true;
@@ -8230,6 +8206,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
8230
8206
  paramSpecTypeVarContext.forEach((paramSpecTypeVarContext) => {
8231
8207
  if (paramSpecTypeVarContext) {
8232
8208
  specializedReturnType = (0, typeUtils_1.applySolvedTypeVars)(specializedReturnType, paramSpecTypeVarContext);
8209
+ // It's possible that one or more of the TypeVars or ParamSpecs
8210
+ // in the typeVarContext refer to TypeVars that were solved in
8211
+ // the paramSpecTypeVarContext. Apply these solved TypeVars accordingly.
8212
+ (0, typeUtils_1.applySourceContextTypeVars)(typeVarContext, paramSpecTypeVarContext);
8233
8213
  }
8234
8214
  });
8235
8215
  }
@@ -8636,7 +8616,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
8636
8616
  // printing types if the diagnostic is disabled.
8637
8617
  const fileInfo = AnalyzerNodeInfo.getFileInfo(argParam.errorNode);
8638
8618
  if (fileInfo.diagnosticRuleSet.reportArgumentType !== 'none' &&
8639
- !isDiagnosticSuppressedForNode(argParam.errorNode) &&
8619
+ !canSkipDiagnosticForNode(argParam.errorNode) &&
8640
8620
  !isTypeIncomplete) {
8641
8621
  const argTypeText = printType(argType);
8642
8622
  const paramTypeText = printType(argParam.paramType);
@@ -10178,9 +10158,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
10178
10158
  }
10179
10159
  }, {
10180
10160
  dependentType: inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.expectedType,
10181
- allowDiagnostics: !forceSpeculative &&
10182
- !isDiagnosticSuppressedForNode(node) &&
10183
- !(inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.isTypeIncomplete),
10161
+ allowDiagnostics: !forceSpeculative && !canSkipDiagnosticForNode(node) && !(inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.isTypeIncomplete),
10184
10162
  });
10185
10163
  // Mark the function type as no longer being evaluated.
10186
10164
  functionType.details.flags &= ~131072 /* FunctionTypeFlags.PartiallyEvaluated */;
@@ -11458,87 +11436,87 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
11458
11436
  writeTypeCache(node.rightExpression, { type: rightHandType }, 0 /* EvaluatorFlags.None */);
11459
11437
  }
11460
11438
  }
11461
- if (!rightHandType) {
11462
- // Determine whether there is a declared type.
11463
- const declaredType = getDeclaredTypeForExpression(node.leftExpression, {
11464
- method: 'set',
11465
- });
11466
- let typeAliasNameNode;
11467
- let isSpeculativeTypeAlias = false;
11468
- if (isDeclaredTypeAlias(node.leftExpression)) {
11469
- typeAliasNameNode = node.leftExpression.valueExpression;
11470
- if (!isLegalTypeAliasExpressionForm(node.rightExpression)) {
11471
- addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeForm, localize_1.LocMessage.typeAliasIllegalExpressionForm(), node.rightExpression);
11472
- }
11473
- }
11474
- else if (node.leftExpression.nodeType === 38 /* ParseNodeType.Name */) {
11475
- const symbolWithScope = lookUpSymbolRecursive(node.leftExpression, node.leftExpression.value,
11476
- /* honorCodeFlow */ false);
11477
- if (symbolWithScope) {
11478
- const decls = symbolWithScope.symbol.getDeclarations();
11479
- if (decls.length === 1 && isPossibleTypeAliasOrTypedDict(decls[0])) {
11480
- typeAliasNameNode = node.leftExpression;
11481
- isSpeculativeTypeAlias = true;
11482
- }
11483
- }
11484
- }
11485
- // Synthesize a type variable that represents the type alias while we're
11486
- // evaluating it. This allows us to handle recursive definitions.
11487
- let typeAliasTypeVar;
11488
- if (typeAliasNameNode) {
11489
- typeAliasTypeVar = types_1.TypeVarType.createInstantiable(`__type_alias_${typeAliasNameNode.value}`);
11490
- typeAliasTypeVar.details.isSynthesized = true;
11491
- typeAliasTypeVar.details.recursiveTypeAliasName = typeAliasNameNode.value;
11492
- const scopeId = ParseTreeUtils.getScopeIdForNode(typeAliasNameNode);
11493
- typeAliasTypeVar.details.recursiveTypeAliasScopeId = scopeId;
11494
- typeAliasTypeVar.details.recursiveTypeAliasIsPep695Syntax = false;
11495
- typeAliasTypeVar.scopeId = scopeId;
11496
- // Write the type back to the type cache. It will be replaced below.
11497
- writeTypeCache(node, { type: typeAliasTypeVar }, /* flags */ undefined);
11498
- writeTypeCache(node.leftExpression, { type: typeAliasTypeVar }, /* flags */ undefined);
11499
- if (node.leftExpression.nodeType === 54 /* ParseNodeType.TypeAnnotation */) {
11500
- writeTypeCache(node.leftExpression.valueExpression, { type: typeAliasTypeVar },
11501
- /* flags */ undefined);
11502
- }
11503
- }
11504
- const srcTypeResult = getTypeOfExpression(node.rightExpression, flags, (0, typeUtils_1.makeInferenceContext)(declaredType));
11505
- let srcType = srcTypeResult.type;
11506
- expectedTypeDiagAddendum = srcTypeResult.expectedTypeDiagAddendum;
11507
- if (srcTypeResult.isIncomplete) {
11508
- isIncomplete = true;
11439
+ }
11440
+ if (!rightHandType) {
11441
+ // Determine whether there is a declared type.
11442
+ const declaredType = getDeclaredTypeForExpression(node.leftExpression, {
11443
+ method: 'set',
11444
+ });
11445
+ let typeAliasNameNode;
11446
+ let isSpeculativeTypeAlias = false;
11447
+ if (isDeclaredTypeAlias(node.leftExpression)) {
11448
+ typeAliasNameNode = node.leftExpression.valueExpression;
11449
+ if (!isLegalTypeAliasExpressionForm(node.rightExpression)) {
11450
+ addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeForm, localize_1.LocMessage.typeAliasIllegalExpressionForm(), node.rightExpression);
11509
11451
  }
11510
- // If the RHS is a constant boolean expression, assign it a literal type.
11511
- const constExprValue = (0, staticExpressions_1.evaluateStaticBoolExpression)(node.rightExpression, fileInfo.executionEnvironment, fileInfo.definedConstants);
11512
- if (constExprValue !== undefined) {
11513
- const boolType = getBuiltInObject(node, 'bool');
11514
- if ((0, types_1.isClassInstance)(boolType)) {
11515
- srcType = types_1.ClassType.cloneWithLiteral(boolType, constExprValue);
11516
- }
11517
- }
11518
- // If this is an enum, transform the type as required.
11519
- rightHandType = srcType;
11520
- if (typeAliasNameNode) {
11521
- // If this was a speculative type alias, it becomes a real type alias
11522
- // only if the evaluated type is an instantiable type.
11523
- if (!isSpeculativeTypeAlias || isLegalImplicitTypeAliasType(rightHandType)) {
11524
- // If this is a type alias, record its name based on the assignment target.
11525
- rightHandType = transformTypeForTypeAlias(rightHandType, typeAliasNameNode, typeAliasNameNode,
11526
- /* isPep695Syntax */ false,
11527
- /* isPep695TypeVarType */ false);
11528
- (0, debug_1.assert)(typeAliasTypeVar !== undefined);
11529
- if ((0, typeUtils_1.isTypeAliasRecursive)(typeAliasTypeVar, rightHandType)) {
11530
- addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typeAliasIsRecursiveDirect().format({
11531
- name: typeAliasNameNode.value,
11532
- }), node.rightExpression);
11533
- rightHandType = types_1.UnknownType.create();
11534
- }
11535
- // Set the resulting type to the boundType of the original type alias
11536
- // to support recursive type aliases.
11537
- typeAliasTypeVar.details.boundType = rightHandType;
11538
- // Record the type parameters within the recursive type alias so it
11539
- // can be specialized.
11540
- typeAliasTypeVar.details.recursiveTypeParameters = (_a = rightHandType.typeAliasInfo) === null || _a === void 0 ? void 0 : _a.typeParameters;
11452
+ }
11453
+ else if (node.leftExpression.nodeType === 38 /* ParseNodeType.Name */) {
11454
+ const symbolWithScope = lookUpSymbolRecursive(node.leftExpression, node.leftExpression.value,
11455
+ /* honorCodeFlow */ false);
11456
+ if (symbolWithScope) {
11457
+ const decls = symbolWithScope.symbol.getDeclarations();
11458
+ if (decls.length === 1 && isPossibleTypeAliasOrTypedDict(decls[0])) {
11459
+ typeAliasNameNode = node.leftExpression;
11460
+ isSpeculativeTypeAlias = true;
11461
+ }
11462
+ }
11463
+ }
11464
+ // Synthesize a type variable that represents the type alias while we're
11465
+ // evaluating it. This allows us to handle recursive definitions.
11466
+ let typeAliasTypeVar;
11467
+ if (typeAliasNameNode) {
11468
+ typeAliasTypeVar = types_1.TypeVarType.createInstantiable(`__type_alias_${typeAliasNameNode.value}`);
11469
+ typeAliasTypeVar.details.isSynthesized = true;
11470
+ typeAliasTypeVar.details.recursiveTypeAliasName = typeAliasNameNode.value;
11471
+ const scopeId = ParseTreeUtils.getScopeIdForNode(typeAliasNameNode);
11472
+ typeAliasTypeVar.details.recursiveTypeAliasScopeId = scopeId;
11473
+ typeAliasTypeVar.details.recursiveTypeAliasIsPep695Syntax = false;
11474
+ typeAliasTypeVar.scopeId = scopeId;
11475
+ // Write the type back to the type cache. It will be replaced below.
11476
+ writeTypeCache(node, { type: typeAliasTypeVar }, /* flags */ undefined);
11477
+ writeTypeCache(node.leftExpression, { type: typeAliasTypeVar }, /* flags */ undefined);
11478
+ if (node.leftExpression.nodeType === 54 /* ParseNodeType.TypeAnnotation */) {
11479
+ writeTypeCache(node.leftExpression.valueExpression, { type: typeAliasTypeVar },
11480
+ /* flags */ undefined);
11481
+ }
11482
+ }
11483
+ const srcTypeResult = getTypeOfExpression(node.rightExpression, flags, (0, typeUtils_1.makeInferenceContext)(declaredType));
11484
+ let srcType = srcTypeResult.type;
11485
+ expectedTypeDiagAddendum = srcTypeResult.expectedTypeDiagAddendum;
11486
+ if (srcTypeResult.isIncomplete) {
11487
+ isIncomplete = true;
11488
+ }
11489
+ // If the RHS is a constant boolean expression, assign it a literal type.
11490
+ const constExprValue = (0, staticExpressions_1.evaluateStaticBoolExpression)(node.rightExpression, fileInfo.executionEnvironment, fileInfo.definedConstants);
11491
+ if (constExprValue !== undefined) {
11492
+ const boolType = getBuiltInObject(node, 'bool');
11493
+ if ((0, types_1.isClassInstance)(boolType)) {
11494
+ srcType = types_1.ClassType.cloneWithLiteral(boolType, constExprValue);
11495
+ }
11496
+ }
11497
+ // If this is an enum, transform the type as required.
11498
+ rightHandType = srcType;
11499
+ if (typeAliasNameNode) {
11500
+ // If this was a speculative type alias, it becomes a real type alias
11501
+ // only if the evaluated type is an instantiable type.
11502
+ if (!isSpeculativeTypeAlias || isLegalImplicitTypeAliasType(rightHandType)) {
11503
+ // If this is a type alias, record its name based on the assignment target.
11504
+ rightHandType = transformTypeForTypeAlias(rightHandType, typeAliasNameNode, typeAliasNameNode,
11505
+ /* isPep695Syntax */ false,
11506
+ /* isPep695TypeVarType */ false);
11507
+ (0, debug_1.assert)(typeAliasTypeVar !== undefined);
11508
+ if ((0, typeUtils_1.isTypeAliasRecursive)(typeAliasTypeVar, rightHandType)) {
11509
+ addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typeAliasIsRecursiveDirect().format({
11510
+ name: typeAliasNameNode.value,
11511
+ }), node.rightExpression);
11512
+ rightHandType = types_1.UnknownType.create();
11541
11513
  }
11514
+ // Set the resulting type to the boundType of the original type alias
11515
+ // to support recursive type aliases.
11516
+ typeAliasTypeVar.details.boundType = rightHandType;
11517
+ // Record the type parameters within the recursive type alias so it
11518
+ // can be specialized.
11519
+ typeAliasTypeVar.details.recursiveTypeParameters = (_a = rightHandType.typeAliasInfo) === null || _a === void 0 ? void 0 : _a.typeParameters;
11542
11520
  }
11543
11521
  }
11544
11522
  }
@@ -13373,6 +13351,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
13373
13351
  !functionDecl.raiseStatements) {
13374
13352
  return false;
13375
13353
  }
13354
+ const statements = functionDecl.node.suite.statements;
13355
+ if (statements.some((statement) => statement.nodeType !== 47 /* ParseNodeType.StatementList */)) {
13356
+ return false;
13357
+ }
13376
13358
  for (const raiseStatement of functionDecl.raiseStatements) {
13377
13359
  if (!raiseStatement.typeExpression || raiseStatement.valueExpression) {
13378
13360
  return false;
@@ -13902,6 +13884,15 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
13902
13884
  nodeToEvaluate = parent;
13903
13885
  continue;
13904
13886
  }
13887
+ // Forward-declared type annotation expressions need to be be evaluated
13888
+ // in context so they have the appropriate flags set. Most of these cases
13889
+ // will have been detected above when calling getParentAnnotationNode,
13890
+ // but TypeAlias expressions are not handled there.
13891
+ const stringEnclosure = ParseTreeUtils.getParentNodeOfType(parent, 48 /* ParseNodeType.StringList */);
13892
+ if (stringEnclosure) {
13893
+ nodeToEvaluate = stringEnclosure;
13894
+ continue;
13895
+ }
13905
13896
  // The left expression of a call or member access expression is not generally contextual.
13906
13897
  if (parent.nodeType === 9 /* ParseNodeType.Call */ || parent.nodeType === 35 /* ParseNodeType.MemberAccess */) {
13907
13898
  if (nodeToEvaluate === parent.leftExpression) {
@@ -13925,17 +13916,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
13925
13916
  // The base expression of an index expression is not contextual.
13926
13917
  if (nodeToEvaluate === parent.baseExpression) {
13927
13918
  flags = 2 /* EvaluatorFlags.IndexBaseDefaults */;
13928
- break;
13929
13919
  }
13930
13920
  }
13931
- else if (parent.nodeType === 48 /* ParseNodeType.StringList */ && nodeToEvaluate === parent.typeAnnotation) {
13932
- // Forward-declared type annotation expressions need to be be evaluated
13933
- // in context so they have the appropriate flags set. Most of these cases
13934
- // will have been detected above when calling getParentAnnotationNode,
13935
- // but TypeAlias expressions are not handled there.
13936
- nodeToEvaluate = parent;
13937
- continue;
13938
- }
13939
13921
  if (!(0, parseNodes_1.isExpressionNode)(parent)) {
13940
13922
  // If we've hit a non-expression node, we generally want to
13941
13923
  // stop. However, there are a few special "pass through"
@@ -14208,7 +14190,16 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
14208
14190
  // don't bother doing additional work.
14209
14191
  let cacheEntry = readTypeCacheEntry(subnode);
14210
14192
  if (cacheEntry && !cacheEntry.typeResult.isIncomplete) {
14211
- return cacheEntry.typeResult;
14193
+ const typeResult = cacheEntry.typeResult;
14194
+ // Handle the special case where a function or class is partially evaluated.
14195
+ // Indicate that these are not complete types.
14196
+ if ((0, types_1.isFunction)(typeResult.type) && types_1.FunctionType.isPartiallyEvaluated(typeResult.type)) {
14197
+ return { ...typeResult, isIncomplete: true };
14198
+ }
14199
+ if ((0, types_1.isClass)(typeResult.type) && types_1.ClassType.isPartiallyEvaluated(typeResult.type)) {
14200
+ return { ...typeResult, isIncomplete: true };
14201
+ }
14202
+ return typeResult;
14212
14203
  }
14213
14204
  callback();
14214
14205
  cacheEntry = readTypeCacheEntry(subnode);
@@ -14234,7 +14225,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
14234
14225
  }
14235
14226
  }
14236
14227
  // Allocate a new code flow analyzer.
14237
- const analyzer = codeFlowEngine.createCodeFlowAnalyzer(typeAtStart);
14228
+ const analyzer = codeFlowEngine.createCodeFlowAnalyzer();
14238
14229
  if (entries) {
14239
14230
  entries.push({ typeAtStart, codeFlowAnalyzer: analyzer });
14240
14231
  }
@@ -14327,6 +14318,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
14327
14318
  0) {
14328
14319
  addError(localize_1.LocMessage.protocolNotAllowed(), errorNode);
14329
14320
  }
14321
+ typeArgs === null || typeArgs === void 0 ? void 0 : typeArgs.forEach((typeArg) => {
14322
+ if (typeArg.typeList || !(0, types_1.isTypeVar)(typeArg.type)) {
14323
+ addError(localize_1.LocMessage.protocolTypeArgMustBeTypeParam(), typeArg.node);
14324
+ }
14325
+ });
14330
14326
  return {
14331
14327
  type: createSpecialType(classType, typeArgs,
14332
14328
  /* paramLimit */ undefined,
@@ -14445,18 +14441,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
14445
14441
  if (firstDefaultParamIndex >= 0) {
14446
14442
  minTypeArgCount = firstDefaultParamIndex;
14447
14443
  }
14448
- // Classes that accept inlined type dict type args allow only one.
14449
- if (typeArgs[0].inlinedTypeDict) {
14450
- if (typeArgs.length > 1) {
14451
- addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeArguments, localize_1.LocMessage.typeArgsTooMany().format({
14452
- name: classType.aliasName || classType.details.name,
14453
- expected: 1,
14454
- received: typeArgCount,
14455
- }), typeArgs[1].node);
14456
- }
14457
- return { type: typeArgs[0].inlinedTypeDict };
14458
- }
14459
- else if (typeArgCount > typeParameters.length) {
14444
+ if (typeArgCount > typeParameters.length) {
14460
14445
  if (!types_1.ClassType.isPartiallyEvaluated(classType) && !types_1.ClassType.isTupleClass(classType)) {
14461
14446
  if (typeParameters.length === 0) {
14462
14447
  addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeArguments, localize_1.LocMessage.typeArgsExpectingNone().format({
@@ -14839,11 +14824,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
14839
14824
  return symbolWithScope;
14840
14825
  }
14841
14826
  // Disables recording of errors and warnings.
14842
- function suppressDiagnostics(node, callback) {
14843
- suppressedNodeStack.push(node);
14827
+ function suppressDiagnostics(node, callback, diagCallback) {
14828
+ suppressedNodeStack.push({ node, suppressedDiags: diagCallback ? [] : undefined });
14844
14829
  try {
14845
14830
  const result = callback();
14846
- suppressedNodeStack.pop();
14831
+ const poppedNode = suppressedNodeStack.pop();
14832
+ if (diagCallback && (poppedNode === null || poppedNode === void 0 ? void 0 : poppedNode.suppressedDiags)) {
14833
+ diagCallback(poppedNode.suppressedDiags);
14834
+ }
14847
14835
  return result;
14848
14836
  }
14849
14837
  catch (e) {
@@ -16090,7 +16078,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
16090
16078
  const prevTypeCache = returnTypeInferenceTypeCache;
16091
16079
  returnTypeInferenceContextStack.push({
16092
16080
  functionNode,
16093
- codeFlowAnalyzer: codeFlowEngine.createCodeFlowAnalyzer(/* typeAtStart */ undefined),
16081
+ codeFlowAnalyzer: codeFlowEngine.createCodeFlowAnalyzer(),
16094
16082
  });
16095
16083
  try {
16096
16084
  returnTypeInferenceTypeCache = new Map();
@@ -16503,6 +16491,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
16503
16491
  while (destTypeArgs.length > srcTypeArgs.length && destTypeArgs[destTypeArgs.length - 1].isOptional) {
16504
16492
  destTypeArgs.splice(destTypeArgs.length - 1, 1);
16505
16493
  }
16494
+ const srcArgsToCapture = srcTypeArgs.length - destTypeArgs.length + 1;
16495
+ let skipAdjustSrc = false;
16506
16496
  // If we're doing reverse type mappings and the source contains a variadic
16507
16497
  // TypeVar, we need to adjust the dest so the reverse type mapping assignment
16508
16498
  // can be performed.
@@ -16528,10 +16518,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
16528
16518
  isUnbounded: false,
16529
16519
  });
16530
16520
  }
16521
+ skipAdjustSrc = true;
16531
16522
  }
16532
16523
  }
16533
16524
  else {
16534
- const srcArgsToCapture = srcTypeArgs.length - destTypeArgs.length + 1;
16535
16525
  if (destUnboundedOrVariadicIndex >= 0 && srcArgsToCapture >= 0) {
16536
16526
  // If the dest contains a variadic element, determine which source
16537
16527
  // args map to this element and package them up into an unpacked tuple.
@@ -16560,30 +16550,27 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
16560
16550
  isUnbounded: false,
16561
16551
  });
16562
16552
  }
16553
+ skipAdjustSrc = true;
16563
16554
  }
16564
- else {
16565
- // If possible, package up the source entries that correspond to
16566
- // the dest unbounded tuple. This isn't possible if the source contains
16567
- // an unbounded tuple outside of this range.
16568
- if (srcUnboundedIndex < 0 ||
16569
- (srcUnboundedIndex >= destUnboundedOrVariadicIndex &&
16570
- srcUnboundedIndex < destUnboundedOrVariadicIndex + srcArgsToCapture)) {
16571
- const removedArgTypes = srcTypeArgs
16572
- .splice(destUnboundedOrVariadicIndex, srcArgsToCapture)
16573
- .map((t) => {
16574
- if ((0, types_1.isTypeVar)(t.type) &&
16575
- (0, types_1.isUnpackedVariadicTypeVar)(t.type) &&
16576
- !t.type.isVariadicInUnion) {
16577
- return types_1.TypeVarType.cloneForUnpacked(t.type, /* isInUnion */ true);
16578
- }
16579
- return t.type;
16580
- });
16581
- srcTypeArgs.splice(destUnboundedOrVariadicIndex, 0, {
16582
- type: removedArgTypes.length > 0 ? (0, types_1.combineTypes)(removedArgTypes) : types_1.AnyType.create(),
16583
- isUnbounded: false,
16584
- });
16555
+ }
16556
+ }
16557
+ if (!skipAdjustSrc && destUnboundedOrVariadicIndex >= 0 && srcArgsToCapture >= 0) {
16558
+ // If possible, package up the source entries that correspond to
16559
+ // the dest unbounded tuple. This isn't possible if the source contains
16560
+ // an unbounded tuple outside of this range.
16561
+ if (srcUnboundedIndex < 0 ||
16562
+ (srcUnboundedIndex >= destUnboundedOrVariadicIndex &&
16563
+ srcUnboundedIndex < destUnboundedOrVariadicIndex + srcArgsToCapture)) {
16564
+ const removedArgTypes = srcTypeArgs.splice(destUnboundedOrVariadicIndex, srcArgsToCapture).map((t) => {
16565
+ if ((0, types_1.isTypeVar)(t.type) && (0, types_1.isUnpackedVariadicTypeVar)(t.type) && !t.type.isVariadicInUnion) {
16566
+ return types_1.TypeVarType.cloneForUnpacked(t.type, /* isInUnion */ true);
16585
16567
  }
16586
- }
16568
+ return t.type;
16569
+ });
16570
+ srcTypeArgs.splice(destUnboundedOrVariadicIndex, 0, {
16571
+ type: removedArgTypes.length > 0 ? (0, types_1.combineTypes)(removedArgTypes) : types_1.AnyType.create(),
16572
+ isUnbounded: false,
16573
+ });
16587
16574
  }
16588
16575
  }
16589
16576
  return destTypeArgs.length === srcTypeArgs.length;
@@ -17367,7 +17354,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
17367
17354
  return true;
17368
17355
  }
17369
17356
  if ((0, types_1.isFunction)(concreteSrcType)) {
17370
- if (assignFunction(destType, concreteSrcType, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), destTypeVarContext !== null && destTypeVarContext !== void 0 ? destTypeVarContext : new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(destType)), srcTypeVarContext !== null && srcTypeVarContext !== void 0 ? srcTypeVarContext : new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeIds)(concreteSrcType)), flags, recursionCount)) {
17357
+ if (assignFunction(destType, concreteSrcType, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), destTypeVarContext !== null && destTypeVarContext !== void 0 ? destTypeVarContext : new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeIds)(destType)), srcTypeVarContext !== null && srcTypeVarContext !== void 0 ? srcTypeVarContext : new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeIds)(concreteSrcType)), flags, recursionCount)) {
17371
17358
  return true;
17372
17359
  }
17373
17360
  }