@zzzen/pyright-internal 1.2.0-dev.20240707 → 1.2.0-dev.20240721

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 (184) hide show
  1. package/dist/analyzer/analyzerNodeInfo.js +74 -46
  2. package/dist/analyzer/analyzerNodeInfo.js.map +1 -1
  3. package/dist/analyzer/binder.js +506 -512
  4. package/dist/analyzer/binder.js.map +1 -1
  5. package/dist/analyzer/checker.js +672 -655
  6. package/dist/analyzer/checker.js.map +1 -1
  7. package/dist/analyzer/codeFlowEngine.d.ts +5 -3
  8. package/dist/analyzer/codeFlowEngine.js +112 -103
  9. package/dist/analyzer/codeFlowEngine.js.map +1 -1
  10. package/dist/analyzer/codeFlowTypes.js +30 -28
  11. package/dist/analyzer/codeFlowTypes.js.map +1 -1
  12. package/dist/analyzer/constraintSolver.js +70 -66
  13. package/dist/analyzer/constraintSolver.js.map +1 -1
  14. package/dist/analyzer/constructorTransform.d.ts +1 -2
  15. package/dist/analyzer/constructorTransform.js +26 -27
  16. package/dist/analyzer/constructorTransform.js.map +1 -1
  17. package/dist/analyzer/constructors.d.ts +2 -2
  18. package/dist/analyzer/constructors.js +95 -190
  19. package/dist/analyzer/constructors.js.map +1 -1
  20. package/dist/analyzer/dataClasses.js +110 -179
  21. package/dist/analyzer/dataClasses.js.map +1 -1
  22. package/dist/analyzer/declarationUtils.js +14 -15
  23. package/dist/analyzer/declarationUtils.js.map +1 -1
  24. package/dist/analyzer/decorators.js +78 -79
  25. package/dist/analyzer/decorators.js.map +1 -1
  26. package/dist/analyzer/enums.js +70 -56
  27. package/dist/analyzer/enums.js.map +1 -1
  28. package/dist/analyzer/functionTransform.js +8 -18
  29. package/dist/analyzer/functionTransform.js.map +1 -1
  30. package/dist/analyzer/importResolver.d.ts +2 -1
  31. package/dist/analyzer/importResolver.js +40 -29
  32. package/dist/analyzer/importResolver.js.map +1 -1
  33. package/dist/analyzer/importStatementUtils.js +27 -27
  34. package/dist/analyzer/importStatementUtils.js.map +1 -1
  35. package/dist/analyzer/namedTuples.js +33 -59
  36. package/dist/analyzer/namedTuples.js.map +1 -1
  37. package/dist/analyzer/operations.js +194 -145
  38. package/dist/analyzer/operations.js.map +1 -1
  39. package/dist/analyzer/packageTypeVerifier.js +66 -62
  40. package/dist/analyzer/packageTypeVerifier.js.map +1 -1
  41. package/dist/analyzer/parameterUtils.d.ts +4 -4
  42. package/dist/analyzer/parameterUtils.js +30 -47
  43. package/dist/analyzer/parameterUtils.js.map +1 -1
  44. package/dist/analyzer/parseTreeUtils.d.ts +1 -0
  45. package/dist/analyzer/parseTreeUtils.js +294 -272
  46. package/dist/analyzer/parseTreeUtils.js.map +1 -1
  47. package/dist/analyzer/parseTreeWalker.js +76 -76
  48. package/dist/analyzer/parseTreeWalker.js.map +1 -1
  49. package/dist/analyzer/patternMatching.js +178 -145
  50. package/dist/analyzer/patternMatching.js.map +1 -1
  51. package/dist/analyzer/program.js +1 -1
  52. package/dist/analyzer/program.js.map +1 -1
  53. package/dist/analyzer/properties.js +82 -147
  54. package/dist/analyzer/properties.js.map +1 -1
  55. package/dist/analyzer/protocols.js +29 -25
  56. package/dist/analyzer/protocols.js.map +1 -1
  57. package/dist/analyzer/sourceFile.js +3 -3
  58. package/dist/analyzer/sourceFile.js.map +1 -1
  59. package/dist/analyzer/sourceMapper.js +20 -19
  60. package/dist/analyzer/sourceMapper.js.map +1 -1
  61. package/dist/analyzer/staticExpressions.js +83 -84
  62. package/dist/analyzer/staticExpressions.js.map +1 -1
  63. package/dist/analyzer/testWalker.js +15 -3
  64. package/dist/analyzer/testWalker.js.map +1 -1
  65. package/dist/analyzer/tracePrinter.js +20 -20
  66. package/dist/analyzer/tracePrinter.js.map +1 -1
  67. package/dist/analyzer/typeDocStringUtils.js +25 -25
  68. package/dist/analyzer/typeDocStringUtils.js.map +1 -1
  69. package/dist/analyzer/typeEvaluator.js +2443 -2350
  70. package/dist/analyzer/typeEvaluator.js.map +1 -1
  71. package/dist/analyzer/typeEvaluatorTypes.d.ts +13 -9
  72. package/dist/analyzer/typeEvaluatorTypes.js +7 -1
  73. package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
  74. package/dist/analyzer/typeGuards.js +212 -215
  75. package/dist/analyzer/typeGuards.js.map +1 -1
  76. package/dist/analyzer/typePrinter.js +118 -115
  77. package/dist/analyzer/typePrinter.js.map +1 -1
  78. package/dist/analyzer/typeStubWriter.js +104 -103
  79. package/dist/analyzer/typeStubWriter.js.map +1 -1
  80. package/dist/analyzer/typeUtils.d.ts +30 -15
  81. package/dist/analyzer/typeUtils.js +534 -436
  82. package/dist/analyzer/typeUtils.js.map +1 -1
  83. package/dist/analyzer/typeVarContext.js +8 -8
  84. package/dist/analyzer/typeVarContext.js.map +1 -1
  85. package/dist/analyzer/typeWalker.js +13 -10
  86. package/dist/analyzer/typeWalker.js.map +1 -1
  87. package/dist/analyzer/typedDicts.js +97 -199
  88. package/dist/analyzer/typedDicts.js.map +1 -1
  89. package/dist/analyzer/types.d.ts +152 -106
  90. package/dist/analyzer/types.js +695 -496
  91. package/dist/analyzer/types.js.map +1 -1
  92. package/dist/commands/dumpFileDebugInfoCommand.js +34 -34
  93. package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
  94. package/dist/common/fileSystem.d.ts +1 -0
  95. package/dist/common/fileSystem.js.map +1 -1
  96. package/dist/common/fullAccessHost.js +6 -4
  97. package/dist/common/fullAccessHost.js.map +1 -1
  98. package/dist/common/realFileSystem.d.ts +1 -0
  99. package/dist/common/realFileSystem.js +4 -0
  100. package/dist/common/realFileSystem.js.map +1 -1
  101. package/dist/common/textEditTracker.js +14 -14
  102. package/dist/common/textEditTracker.js.map +1 -1
  103. package/dist/languageService/autoImporter.js +10 -10
  104. package/dist/languageService/autoImporter.js.map +1 -1
  105. package/dist/languageService/callHierarchyProvider.js +23 -23
  106. package/dist/languageService/callHierarchyProvider.js.map +1 -1
  107. package/dist/languageService/completionProvider.js +153 -151
  108. package/dist/languageService/completionProvider.js.map +1 -1
  109. package/dist/languageService/definitionProvider.d.ts +1 -1
  110. package/dist/languageService/definitionProvider.js +3 -1
  111. package/dist/languageService/definitionProvider.js.map +1 -1
  112. package/dist/languageService/documentSymbolCollector.js +19 -19
  113. package/dist/languageService/documentSymbolCollector.js.map +1 -1
  114. package/dist/languageService/hoverProvider.js +36 -27
  115. package/dist/languageService/hoverProvider.js.map +1 -1
  116. package/dist/languageService/importSorter.js +8 -8
  117. package/dist/languageService/importSorter.js.map +1 -1
  118. package/dist/languageService/referencesProvider.d.ts +10 -4
  119. package/dist/languageService/referencesProvider.js +30 -18
  120. package/dist/languageService/referencesProvider.js.map +1 -1
  121. package/dist/languageService/renameProvider.js +21 -4
  122. package/dist/languageService/renameProvider.js.map +1 -1
  123. package/dist/languageService/signatureHelpProvider.d.ts +1 -1
  124. package/dist/languageService/signatureHelpProvider.js +6 -6
  125. package/dist/languageService/signatureHelpProvider.js.map +1 -1
  126. package/dist/languageService/symbolIndexer.js +3 -3
  127. package/dist/languageService/symbolIndexer.js.map +1 -1
  128. package/dist/languageService/tooltipUtils.js +13 -13
  129. package/dist/languageService/tooltipUtils.js.map +1 -1
  130. package/dist/localization/localize.d.ts +4 -3
  131. package/dist/localization/localize.js +2 -1
  132. package/dist/localization/localize.js.map +1 -1
  133. package/dist/localization/package.nls.cs.json +0 -1
  134. package/dist/localization/package.nls.de.json +0 -1
  135. package/dist/localization/package.nls.en-us.json +2 -1
  136. package/dist/localization/package.nls.es.json +0 -1
  137. package/dist/localization/package.nls.fr.json +0 -1
  138. package/dist/localization/package.nls.it.json +0 -1
  139. package/dist/localization/package.nls.ja.json +0 -1
  140. package/dist/localization/package.nls.ko.json +0 -1
  141. package/dist/localization/package.nls.pl.json +0 -1
  142. package/dist/localization/package.nls.pt-br.json +0 -1
  143. package/dist/localization/package.nls.qps-ploc.json +0 -1
  144. package/dist/localization/package.nls.ru.json +0 -1
  145. package/dist/localization/package.nls.tr.json +0 -1
  146. package/dist/localization/package.nls.zh-cn.json +0 -1
  147. package/dist/localization/package.nls.zh-tw.json +0 -1
  148. package/dist/parser/parseNodes.d.ts +471 -402
  149. package/dist/parser/parseNodes.js +629 -356
  150. package/dist/parser/parseNodes.js.map +1 -1
  151. package/dist/parser/parser.d.ts +1 -0
  152. package/dist/parser/parser.js +345 -300
  153. package/dist/parser/parser.js.map +1 -1
  154. package/dist/tests/classDeclaration.test.js +14 -14
  155. package/dist/tests/classDeclaration.test.js.map +1 -1
  156. package/dist/tests/fourslash/rename.args.fourslash.d.ts +1 -0
  157. package/dist/tests/fourslash/rename.args.fourslash.js +71 -0
  158. package/dist/tests/fourslash/rename.args.fourslash.js.map +1 -0
  159. package/dist/tests/harness/vfs/filesystem.d.ts +3 -2
  160. package/dist/tests/harness/vfs/filesystem.js +6 -2
  161. package/dist/tests/harness/vfs/filesystem.js.map +1 -1
  162. package/dist/tests/importResolver.test.js +4 -3
  163. package/dist/tests/importResolver.test.js.map +1 -1
  164. package/dist/tests/parseTreeUtils.test.js +5 -5
  165. package/dist/tests/parseTreeUtils.test.js.map +1 -1
  166. package/dist/tests/parser.test.js +8 -8
  167. package/dist/tests/parser.test.js.map +1 -1
  168. package/dist/tests/sourceMapperUtils.test.js +7 -7
  169. package/dist/tests/sourceMapperUtils.test.js.map +1 -1
  170. package/dist/tests/typeEvaluator1.test.js +17 -0
  171. package/dist/tests/typeEvaluator1.test.js.map +1 -1
  172. package/dist/tests/typeEvaluator2.test.js +4 -0
  173. package/dist/tests/typeEvaluator2.test.js.map +1 -1
  174. package/dist/tests/typeEvaluator3.test.js +8 -3
  175. package/dist/tests/typeEvaluator3.test.js.map +1 -1
  176. package/dist/tests/typeEvaluator4.test.js +10 -6
  177. package/dist/tests/typeEvaluator4.test.js.map +1 -1
  178. package/dist/tests/typeEvaluator6.test.js +6 -2
  179. package/dist/tests/typeEvaluator6.test.js.map +1 -1
  180. package/dist/tests/typeEvaluator7.test.js +7 -3
  181. package/dist/tests/typeEvaluator7.test.js.map +1 -1
  182. package/dist/tests/typePrinter.test.js +14 -39
  183. package/dist/tests/typePrinter.test.js.map +1 -1
  184. package/package.json +1 -1
@@ -6,9 +6,11 @@ import { Type, TypeVarType } from './types';
6
6
  export interface FlowNodeTypeResult {
7
7
  type: Type | undefined;
8
8
  isIncomplete: boolean;
9
- generationCount?: number | undefined;
10
- incompleteType?: Type | undefined;
11
- incompleteSubtypes?: IncompleteSubtypeInfo[] | undefined;
9
+ generationCount: number | undefined;
10
+ incompleteSubtypes: IncompleteSubtypeInfo[] | undefined;
11
+ }
12
+ export declare namespace FlowNodeTypeResult {
13
+ function create(type: Type | undefined, isIncomplete: boolean, generationCount?: number, incompleteSubtypes?: IncompleteSubtypeInfo[]): FlowNodeTypeResult;
12
14
  }
13
15
  export interface FlowNodeTypeOptions {
14
16
  targetSymbolId?: number;
@@ -12,7 +12,7 @@
12
12
  * TypeScript compiler.
13
13
  */
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.getCodeFlowEngine = exports.isIncompleteType = void 0;
15
+ exports.getCodeFlowEngine = exports.isIncompleteType = exports.FlowNodeTypeResult = void 0;
16
16
  const debug_1 = require("../common/debug");
17
17
  const positionUtils_1 = require("../common/positionUtils");
18
18
  const analyzerNodeInfo_1 = require("./analyzerNodeInfo");
@@ -25,6 +25,18 @@ const typedDicts_1 = require("./typedDicts");
25
25
  const typeGuards_1 = require("./typeGuards");
26
26
  const types_1 = require("./types");
27
27
  const typeUtils_1 = require("./typeUtils");
28
+ var FlowNodeTypeResult;
29
+ (function (FlowNodeTypeResult) {
30
+ function create(type, isIncomplete, generationCount, incompleteSubtypes) {
31
+ return {
32
+ type,
33
+ isIncomplete,
34
+ generationCount,
35
+ incompleteSubtypes,
36
+ };
37
+ }
38
+ FlowNodeTypeResult.create = create;
39
+ })(FlowNodeTypeResult || (exports.FlowNodeTypeResult = FlowNodeTypeResult = {}));
28
40
  // Define a user type guard function for IncompleteType.
29
41
  function isIncompleteType(cachedType) {
30
42
  return !!cachedType.isIncompleteType;
@@ -39,6 +51,19 @@ const enablePrintCallNoReturn = false;
39
51
  // to determine whether it is `NoReturn`? Enabling this produces more consistent
40
52
  // and complete results, but it can be very expensive.
41
53
  const inferNoReturnForUnannotatedFunctions = false;
54
+ // In rare circumstances, it's possible for types in a loop not to converge. This
55
+ // can happen, for example, if there are many symbols that depend on each other
56
+ // and their types depend on complex overloads that can resolve to Any under
57
+ // certain circumstances. This defines the max number of times we'll attempt to
58
+ // evaluate an antecedent in a loop before we give up and "pin" the evaluated
59
+ // type for that antecedent. The number is somewhat arbitrary. Too low and
60
+ // it will cause incorrect types to be evaluated even when types could converge.
61
+ // Too high, and it will cause long hangs before giving up.
62
+ const maxConvergenceAttemptLimit = 256;
63
+ // Should a message be logged when the convergence limit is hit? This is useful
64
+ // for debugging but not something that is actionable for users, so disable by
65
+ // default.
66
+ const enablePrintConvergenceLimitHit = false;
42
67
  function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
43
68
  const isReachableRecursionSet = new Set();
44
69
  const reachabilityCache = new Map();
@@ -47,6 +72,7 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
47
72
  let flowIncompleteGeneration = 1;
48
73
  let noReturnAnalysisDepth = 0;
49
74
  let contextManagerAnalysisDepth = 0;
75
+ let maxConvergenceLimitHit = false;
50
76
  // Creates a new code flow analyzer that can be used to narrow the types
51
77
  // of the expressions within an execution context. Each code flow analyzer
52
78
  // instance maintains a cache of types it has already determined.
@@ -125,12 +151,7 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
125
151
  : type;
126
152
  flowNodeTypeCache.cache.set(flowNode.id, entry);
127
153
  speculativeTypeTracker.trackEntry(flowNodeTypeCache.cache, flowNode.id);
128
- return {
129
- type,
130
- isIncomplete,
131
- generationCount: flowIncompleteGeneration,
132
- incompleteSubtypes: isIncomplete ? [] : undefined,
133
- };
154
+ return FlowNodeTypeResult.create(type, isIncomplete, flowIncompleteGeneration, isIncomplete ? [] : undefined);
134
155
  }
135
156
  function setIncompleteSubtype(flowNode, index, type, isIncomplete, isPending, evaluationCount) {
136
157
  const cachedEntry = flowNodeTypeCache.cache.get(flowNode.id);
@@ -182,17 +203,13 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
182
203
  }
183
204
  const cachedEntry = flowNodeTypeCache.cache.get(flowNode.id);
184
205
  if (cachedEntry === undefined) {
185
- return { type: undefined, isIncomplete: false };
206
+ return FlowNodeTypeResult.create(/* type */ undefined, /* isIncomplete */ false);
186
207
  }
187
208
  if (!isIncompleteType(cachedEntry)) {
188
- return { type: cachedEntry, isIncomplete: false };
209
+ return FlowNodeTypeResult.create(cachedEntry, /* isIncomplete */ false);
189
210
  }
190
- return {
191
- type: cachedEntry.type,
192
- isIncomplete: true,
193
- incompleteSubtypes: cachedEntry.incompleteSubtypes,
194
- generationCount: cachedEntry.generationCount,
195
- };
211
+ return FlowNodeTypeResult.create(cachedEntry.type,
212
+ /* isIncomplete */ true, cachedEntry.generationCount, cachedEntry.incompleteSubtypes);
196
213
  }
197
214
  function deleteCacheEntry(flowNode) {
198
215
  flowNodeTypeCache.cache.delete(flowNode.id);
@@ -246,18 +263,14 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
246
263
  // If the cached entry is incomplete, we can use it only if nothing
247
264
  // has changed that may cause the previously-reported incomplete type to change.
248
265
  if (cachedEntry.generationCount === flowIncompleteGeneration) {
249
- return {
250
- type: cachedEntry.type ? (0, typeUtils_1.cleanIncompleteUnknown)(cachedEntry.type) : undefined,
251
- isIncomplete: true,
252
- };
266
+ return FlowNodeTypeResult.create(cachedEntry.type ? (0, typeUtils_1.cleanIncompleteUnknown)(cachedEntry.type) : undefined,
267
+ /* isIncomplete */ true);
253
268
  }
254
269
  }
255
270
  // Check for recursion.
256
271
  if (flowNodeTypeCache.pendingNodes.has(curFlowNode.id)) {
257
- return {
258
- type: (_a = cachedEntry === null || cachedEntry === void 0 ? void 0 : cachedEntry.type) !== null && _a !== void 0 ? _a : types_1.UnknownType.create(/* isIncomplete */ true),
259
- isIncomplete: true,
260
- };
272
+ return FlowNodeTypeResult.create((_a = cachedEntry === null || cachedEntry === void 0 ? void 0 : cachedEntry.type) !== null && _a !== void 0 ? _a : types_1.UnknownType.create(/* isIncomplete */ true),
273
+ /* isIncomplete */ true);
261
274
  }
262
275
  if (curFlowNode.flags & codeFlowTypes_1.FlowFlags.Unreachable) {
263
276
  // We can get here if there are nodes in a compound logical expression
@@ -312,10 +325,7 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
312
325
  if (flowTypeResult) {
313
326
  if ((0, typeUtils_1.isTypeAliasPlaceholder)(flowTypeResult.type)) {
314
327
  // Don't cache a recursive type alias placeholder.
315
- return {
316
- type: flowTypeResult.type,
317
- isIncomplete: true,
318
- };
328
+ return FlowNodeTypeResult.create(flowTypeResult.type, /* isIncomplete */ true);
319
329
  }
320
330
  else if (reference.nodeType === 35 /* ParseNodeType.MemberAccess */ &&
321
331
  evaluator.isAsymmetricAccessorAssignment(targetNode)) {
@@ -328,16 +338,16 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
328
338
  // be assigning to a TypedDict, which requires narrowing of the expression's
329
339
  // base type.
330
340
  if (targetNode.nodeType === 27 /* ParseNodeType.Index */ &&
331
- (0, parseTreeUtils_1.isMatchingExpression)(reference, targetNode.baseExpression)) {
341
+ (0, parseTreeUtils_1.isMatchingExpression)(reference, targetNode.d.leftExpr)) {
332
342
  if (((_b = targetNode.parent) === null || _b === void 0 ? void 0 : _b.nodeType) === 3 /* ParseNodeType.Assignment */ &&
333
- targetNode.items.length === 1 &&
334
- !targetNode.trailingComma &&
335
- !targetNode.items[0].name &&
336
- targetNode.items[0].argumentCategory === 0 /* ArgumentCategory.Simple */ &&
337
- targetNode.items[0].valueExpression.nodeType === 48 /* ParseNodeType.StringList */ &&
338
- targetNode.items[0].valueExpression.strings.length === 1 &&
339
- targetNode.items[0].valueExpression.strings[0].nodeType === 49 /* ParseNodeType.String */) {
340
- const keyValue = targetNode.items[0].valueExpression.strings[0].value;
343
+ targetNode.d.items.length === 1 &&
344
+ !targetNode.d.trailingComma &&
345
+ !targetNode.d.items[0].d.name &&
346
+ targetNode.d.items[0].d.argCategory === 0 /* ArgumentCategory.Simple */ &&
347
+ targetNode.d.items[0].d.valueExpr.nodeType === 48 /* ParseNodeType.StringList */ &&
348
+ targetNode.d.items[0].d.valueExpr.d.strings.length === 1 &&
349
+ targetNode.d.items[0].d.valueExpr.d.strings[0].nodeType === 49 /* ParseNodeType.String */) {
350
+ const keyValue = targetNode.d.items[0].d.valueExpr.d.strings[0].d.value;
341
351
  const narrowedResult = preventRecursion(assignmentFlowNode, () => {
342
352
  const flowTypeResult = getTypeFromFlowNode(assignmentFlowNode.antecedent);
343
353
  if (flowTypeResult.type) {
@@ -360,10 +370,7 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
360
370
  // a = Foo()
361
371
  // x = a.b
362
372
  // The type of "a.b" can no longer be assumed to be Literal[3].
363
- return {
364
- type: (_c = options === null || options === void 0 ? void 0 : options.typeAtStart) === null || _c === void 0 ? void 0 : _c.type,
365
- isIncomplete: !!((_d = options === null || options === void 0 ? void 0 : options.typeAtStart) === null || _d === void 0 ? void 0 : _d.isIncomplete),
366
- };
373
+ return FlowNodeTypeResult.create((_c = options === null || options === void 0 ? void 0 : options.typeAtStart) === null || _c === void 0 ? void 0 : _c.type, !!((_d = options === null || options === void 0 ? void 0 : options.typeAtStart) === null || _d === void 0 ? void 0 : _d.isIncomplete));
367
374
  }
368
375
  }
369
376
  curFlowNode = assignmentFlowNode.antecedent;
@@ -451,7 +458,7 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
451
458
  // Make sure the reference type has a declared type. If not,
452
459
  // don't bother trying to infer its type because that would be
453
460
  // too expensive.
454
- const symbolWithScope = evaluator.lookUpSymbolRecursive(conditionalFlowNode.reference, conditionalFlowNode.reference.value,
461
+ const symbolWithScope = evaluator.lookUpSymbolRecursive(conditionalFlowNode.reference, conditionalFlowNode.reference.d.value,
455
462
  /* honorCodeFlow */ false);
456
463
  if (symbolWithScope && symbolWithScope.symbol.hasTypedDeclarations()) {
457
464
  const result = preventRecursion(curFlowNode, () => {
@@ -562,7 +569,7 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
562
569
  if (curFlowNode.flags & codeFlowTypes_1.FlowFlags.WildcardImport) {
563
570
  const wildcardImportFlowNode = curFlowNode;
564
571
  if (reference && reference.nodeType === 38 /* ParseNodeType.Name */) {
565
- const nameValue = reference.value;
572
+ const nameValue = reference.d.value;
566
573
  if (wildcardImportFlowNode.names.some((name) => name === nameValue)) {
567
574
  return preventRecursion(curFlowNode, () => {
568
575
  const type = getTypeFromWildcardImport(wildcardImportFlowNode, nameValue);
@@ -615,10 +622,8 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
615
622
  // If entries have been added for all antecedents and there are pending entries
616
623
  // that have not been evaluated even once, treat it as incomplete. We clean
617
624
  // any incomplete unknowns from the type here to assist with type convergence.
618
- return {
619
- type: cacheEntry.type ? (0, typeUtils_1.cleanIncompleteUnknown)(cacheEntry.type) : undefined,
620
- isIncomplete: true,
621
- };
625
+ return FlowNodeTypeResult.create(cacheEntry.type ? (0, typeUtils_1.cleanIncompleteUnknown)(cacheEntry.type) : undefined,
626
+ /* isIncomplete */ true);
622
627
  }
623
628
  let attemptCount = 0;
624
629
  while (true) {
@@ -671,6 +676,16 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
671
676
  : undefined;
672
677
  if (subtypeEntry === undefined || (!(subtypeEntry === null || subtypeEntry === void 0 ? void 0 : subtypeEntry.isPending) && (subtypeEntry === null || subtypeEntry === void 0 ? void 0 : subtypeEntry.isIncomplete))) {
673
678
  const entryEvaluationCount = subtypeEntry === undefined ? 0 : subtypeEntry.evaluationCount;
679
+ // Does it look like this will never converge? If so, stick with the
680
+ // previously-computed type for this entry.
681
+ if (entryEvaluationCount >= maxConvergenceAttemptLimit) {
682
+ // Log this only once.
683
+ if (!maxConvergenceLimitHit && enablePrintConvergenceLimitHit) {
684
+ console.log('Types failed to converge during code flow analysis');
685
+ }
686
+ maxConvergenceLimitHit = true;
687
+ return;
688
+ }
674
689
  // Set this entry to "pending" to prevent infinite recursion.
675
690
  // We'll mark it "not pending" below.
676
691
  cacheEntry = setIncompleteSubtype(loopNode, index, (_a = subtypeEntry === null || subtypeEntry === void 0 ? void 0 : subtypeEntry.type) !== null && _a !== void 0 ? _a : types_1.UnknownType.create(/* isIncomplete */ true),
@@ -705,7 +720,7 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
705
720
  // entry because we'll overwrite a pending evaluation. The type that
706
721
  // we return here doesn't matter as long as it's not undefined.
707
722
  return sawPending
708
- ? { type: types_1.UnknownType.create(), isIncomplete: false }
723
+ ? FlowNodeTypeResult.create(types_1.UnknownType.create(), /* isIncomplete */ false)
709
724
  : setCacheEntry(loopNode, types_1.UnknownType.create(), /* isIncomplete */ false);
710
725
  }
711
726
  let effectiveType = cacheEntry.type;
@@ -742,12 +757,12 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
742
757
  // other incomplete types based on this now-complete type.
743
758
  flowIncompleteGeneration++;
744
759
  }
745
- return { type: effectiveType, isIncomplete: reportIncomplete };
760
+ return FlowNodeTypeResult.create(effectiveType, reportIncomplete);
746
761
  }
747
762
  // If the first antecedent was pending, we skipped all of the other
748
763
  // antecedents, so the type is incomplete.
749
764
  if (firstAntecedentTypeIsPending) {
750
- return { type: effectiveType, isIncomplete: true };
765
+ return FlowNodeTypeResult.create(effectiveType, /* isIncomplete */ true);
751
766
  }
752
767
  return setCacheEntry(loopNode, effectiveType, /* isIncomplete */ false);
753
768
  }
@@ -757,15 +772,12 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
757
772
  function getTypeFromPreFinallyGateFlowNode(preFinallyFlowNode) {
758
773
  // Is the finally gate closed?
759
774
  if (flowNodeTypeCache.closedFinallyGateNodes.has(preFinallyFlowNode.id)) {
760
- return { type: undefined, isIncomplete: false };
775
+ return FlowNodeTypeResult.create(/* type */ undefined, /* isIncomplete */ false);
761
776
  }
762
777
  const flowTypeResult = getTypeFromFlowNode(preFinallyFlowNode.antecedent);
763
778
  // We want to cache the type only if we're evaluating the "gate closed" path.
764
779
  deleteCacheEntry(preFinallyFlowNode);
765
- return {
766
- type: flowTypeResult.type,
767
- isIncomplete: flowTypeResult.isIncomplete,
768
- };
780
+ return FlowNodeTypeResult.create(flowTypeResult.type, flowTypeResult.isIncomplete);
769
781
  }
770
782
  function getTypeFromPostFinallyFlowNode(postFinallyFlowNode) {
771
783
  const wasGateClosed = flowNodeTypeCache.closedFinallyGateNodes.has(postFinallyFlowNode.preFinallyGate.id);
@@ -794,10 +806,7 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
794
806
  // parse nodes that are created after the initial parse
795
807
  // (namely, string literals that are used for forward
796
808
  // referenced types).
797
- return {
798
- type: (_a = options === null || options === void 0 ? void 0 : options.typeAtStart) === null || _a === void 0 ? void 0 : _a.type,
799
- isIncomplete: !!((_b = options === null || options === void 0 ? void 0 : options.typeAtStart) === null || _b === void 0 ? void 0 : _b.isIncomplete),
800
- };
809
+ return FlowNodeTypeResult.create((_a = options === null || options === void 0 ? void 0 : options.typeAtStart) === null || _a === void 0 ? void 0 : _a.type, !!((_b = options === null || options === void 0 ? void 0 : options.typeAtStart) === null || _b === void 0 ? void 0 : _b.isIncomplete));
801
810
  }
802
811
  return getTypeFromFlowNode(flowNode);
803
812
  }
@@ -892,7 +901,7 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
892
901
  // Make sure the reference type has a declared type. If not,
893
902
  // don't bother trying to infer its type because that would be
894
903
  // too expensive.
895
- const symbolWithScope = evaluator.lookUpSymbolRecursive(conditionalFlowNode.reference, conditionalFlowNode.reference.value,
904
+ const symbolWithScope = evaluator.lookUpSymbolRecursive(conditionalFlowNode.reference, conditionalFlowNode.reference.d.value,
896
905
  /* honorCodeFlow */ false);
897
906
  if (symbolWithScope && symbolWithScope.symbol.hasTypedDeclarations()) {
898
907
  let isUnreachable = false;
@@ -988,13 +997,13 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
988
997
  // can be narrowed to one of its constrained types based on isinstance type
989
998
  // guard checks.
990
999
  function narrowConstrainedTypeVar(flowNode, typeVar) {
991
- (0, debug_1.assert)(!typeVar.details.isParamSpec);
992
- (0, debug_1.assert)(!typeVar.details.isVariadic);
993
- (0, debug_1.assert)(!typeVar.details.boundType);
994
- (0, debug_1.assert)(typeVar.details.constraints.length > 0);
1000
+ (0, debug_1.assert)(!typeVar.shared.isParamSpec);
1001
+ (0, debug_1.assert)(!typeVar.shared.isVariadic);
1002
+ (0, debug_1.assert)(!typeVar.shared.boundType);
1003
+ (0, debug_1.assert)(typeVar.shared.constraints.length > 0);
995
1004
  const visitedFlowNodeMap = new Set();
996
1005
  const startingConstraints = [];
997
- for (const constraint of typeVar.details.constraints) {
1006
+ for (const constraint of typeVar.shared.constraints) {
998
1007
  if ((0, types_1.isClassInstance)(constraint)) {
999
1008
  startingConstraints.push(constraint);
1000
1009
  }
@@ -1033,12 +1042,12 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
1033
1042
  if (narrowForPatternFlowNode.statement.nodeType === 64 /* ParseNodeType.Case */) {
1034
1043
  const subjectType = evaluator.getTypeOfExpression(narrowForPatternFlowNode.subjectExpression).type;
1035
1044
  if (isCompatibleWithConstrainedTypeVar(subjectType, typeVar)) {
1036
- const patternNode = narrowForPatternFlowNode.statement.pattern;
1045
+ const patternNode = narrowForPatternFlowNode.statement.d.pattern;
1037
1046
  if (patternNode.nodeType === 66 /* ParseNodeType.PatternAs */ &&
1038
- patternNode.orPatterns.length === 1 &&
1039
- patternNode.orPatterns[0].nodeType === 68 /* ParseNodeType.PatternClass */) {
1040
- const classPatternNode = patternNode.orPatterns[0];
1041
- const classType = evaluator.getTypeOfExpression(classPatternNode.className, 2 /* EvalFlags.CallBaseDefaults */).type;
1047
+ patternNode.d.orPatterns.length === 1 &&
1048
+ patternNode.d.orPatterns[0].nodeType === 68 /* ParseNodeType.PatternClass */) {
1049
+ const classPatternNode = patternNode.d.orPatterns[0];
1050
+ const classType = evaluator.getTypeOfExpression(classPatternNode.d.className, 2 /* EvalFlags.CallBaseDefaults */).type;
1042
1051
  if ((0, types_1.isInstantiableClass)(classType)) {
1043
1052
  const priorRemainingConstraints = narrowConstrainedTypeVarRecursive(narrowForPatternFlowNode.antecedent, typeVar);
1044
1053
  return priorRemainingConstraints.filter((subtype) => types_1.ClassType.isSameGenericClass(subtype, classType));
@@ -1055,17 +1064,17 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
1055
1064
  const testExpression = conditionFlowNode.expression;
1056
1065
  const isPositiveTest = (curFlowNode.flags & codeFlowTypes_1.FlowFlags.TrueCondition) !== 0;
1057
1066
  if (testExpression.nodeType === 9 /* ParseNodeType.Call */ &&
1058
- testExpression.leftExpression.nodeType === 38 /* ParseNodeType.Name */ &&
1059
- testExpression.leftExpression.value === 'isinstance' &&
1060
- testExpression.arguments.length === 2) {
1061
- const arg0Expr = testExpression.arguments[0].valueExpression;
1067
+ testExpression.d.leftExpr.nodeType === 38 /* ParseNodeType.Name */ &&
1068
+ testExpression.d.leftExpr.d.value === 'isinstance' &&
1069
+ testExpression.d.args.length === 2) {
1070
+ const arg0Expr = testExpression.d.args[0].d.valueExpr;
1062
1071
  const arg0Type = evaluator.getTypeOfExpression(arg0Expr).type;
1063
1072
  if (isCompatibleWithConstrainedTypeVar(arg0Type, typeVar)) {
1064
1073
  // Prevent infinite recursion by noting that we've been here before.
1065
1074
  visitedFlowNodeMap.add(curFlowNode.id);
1066
1075
  const priorRemainingConstraints = narrowConstrainedTypeVarRecursive(conditionFlowNode.antecedent, typeVar);
1067
1076
  visitedFlowNodeMap.delete(curFlowNode.id);
1068
- const arg1Expr = testExpression.arguments[1].valueExpression;
1077
+ const arg1Expr = testExpression.d.args[1].d.valueExpr;
1069
1078
  const arg1Type = evaluator.getTypeOfExpression(arg1Expr, 512 /* EvalFlags.AllowMissingTypeArgs */ |
1070
1079
  8 /* EvalFlags.StrLiteralAsType */ |
1071
1080
  32 /* EvalFlags.NoParamSpec */ |
@@ -1118,14 +1127,15 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
1118
1127
  function isCompatibleWithConstrainedTypeVar(type, typeVar) {
1119
1128
  let isCompatible = true;
1120
1129
  (0, typeUtils_1.doForEachSubtype)(type, (subtype) => {
1130
+ var _a;
1121
1131
  if ((0, types_1.isTypeVar)(subtype)) {
1122
1132
  if (!(0, types_1.isTypeSame)(subtype, typeVar)) {
1123
1133
  isCompatible = false;
1124
1134
  }
1125
1135
  }
1126
- else if (subtype.condition) {
1127
- if (!subtype.condition.some((condition) => condition.typeVar.details.constraints.length > 0 &&
1128
- condition.typeVar.nameWithScope === typeVar.nameWithScope)) {
1136
+ else if ((_a = subtype.props) === null || _a === void 0 ? void 0 : _a.condition) {
1137
+ if (!subtype.props.condition.some((condition) => condition.typeVar.shared.constraints.length > 0 &&
1138
+ condition.typeVar.priv.nameWithScope === typeVar.priv.nameWithScope)) {
1129
1139
  isCompatible = false;
1130
1140
  }
1131
1141
  }
@@ -1156,7 +1166,7 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
1156
1166
  }
1157
1167
  // Don't attempt to evaluate a lambda call. We need to evaluate these in the
1158
1168
  // context of its arguments.
1159
- if (node.leftExpression.nodeType === 33 /* ParseNodeType.Lambda */) {
1169
+ if (node.d.leftExpr.nodeType === 33 /* ParseNodeType.Lambda */) {
1160
1170
  return false;
1161
1171
  }
1162
1172
  // Initially set to false to avoid recursion.
@@ -1166,7 +1176,7 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
1166
1176
  let noReturnTypeCount = 0;
1167
1177
  let subtypeCount = 0;
1168
1178
  // Evaluate the call base type.
1169
- const callTypeResult = evaluator.getTypeOfExpression(node.leftExpression, 2 /* EvalFlags.CallBaseDefaults */);
1179
+ const callTypeResult = evaluator.getTypeOfExpression(node.d.leftExpr, 2 /* EvalFlags.CallBaseDefaults */);
1170
1180
  const callType = callTypeResult.type;
1171
1181
  (0, typeUtils_1.doForEachSubtype)(callType, (callSubtype) => {
1172
1182
  var _a;
@@ -1217,11 +1227,10 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
1217
1227
  else {
1218
1228
  // Perform a more complete evaluation to determine whether
1219
1229
  // the applicable overload returns a NoReturn.
1220
- const callResult = evaluator.validateOverloadedFunctionArguments(node, node.arguments, { type: callSubtype, isIncomplete: callTypeResult.isIncomplete },
1230
+ const callResult = evaluator.validateOverloadedArgTypes(node, node.d.args.map((arg) => (0, typeUtils_1.convertArgumentNodeToFunctionArgument)(arg)), { type: callSubtype, isIncomplete: callTypeResult.isIncomplete },
1221
1231
  /* typeVarContext */ undefined,
1222
1232
  /* skipUnknownArgCheck */ false,
1223
- /* inferenceContext */ undefined,
1224
- /* signatureTracker */ undefined);
1233
+ /* inferenceContext */ undefined);
1225
1234
  if (callResult.returnType && (0, types_1.isNever)(callResult.returnType)) {
1226
1235
  noReturnTypeCount++;
1227
1236
  }
@@ -1243,13 +1252,13 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
1243
1252
  }
1244
1253
  }
1245
1254
  function isFunctionNoReturn(functionType, isCallAwaited) {
1246
- const returnType = functionType.details.declaredReturnType;
1255
+ const returnType = functionType.shared.declaredReturnType;
1247
1256
  if (returnType) {
1248
1257
  if ((0, types_1.isClassInstance)(returnType) &&
1249
1258
  types_1.ClassType.isBuiltIn(returnType, 'Coroutine') &&
1250
- returnType.typeArguments &&
1251
- returnType.typeArguments.length >= 3) {
1252
- if ((0, types_1.isNever)(returnType.typeArguments[2]) && isCallAwaited) {
1259
+ returnType.priv.typeArguments &&
1260
+ returnType.priv.typeArguments.length >= 3) {
1261
+ if ((0, types_1.isNever)(returnType.priv.typeArguments[2]) && isCallAwaited) {
1253
1262
  return true;
1254
1263
  }
1255
1264
  }
@@ -1258,29 +1267,29 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
1258
1267
  else if (!inferNoReturnForUnannotatedFunctions) {
1259
1268
  return false;
1260
1269
  }
1261
- else if (functionType.details.declaration) {
1270
+ else if (functionType.shared.declaration) {
1262
1271
  // If the function is a generator (i.e. it has yield statements)
1263
1272
  // then it is not a "no return" call. Also, don't infer a "no
1264
1273
  // return" type for abstract methods.
1265
- if (!functionType.details.declaration.isGenerator &&
1274
+ if (!functionType.shared.declaration.isGenerator &&
1266
1275
  !types_1.FunctionType.isAbstractMethod(functionType) &&
1267
1276
  !types_1.FunctionType.isStubDefinition(functionType) &&
1268
1277
  !types_1.FunctionType.isPyTypedDefinition(functionType)) {
1269
1278
  // Check specifically for a common idiom where the only statement
1270
1279
  // (other than a possible docstring) is a "raise NotImplementedError".
1271
- const functionStatements = functionType.details.declaration.node.suite.statements;
1280
+ const functionStatements = functionType.shared.declaration.node.d.suite.d.statements;
1272
1281
  let foundRaiseNotImplemented = false;
1273
1282
  for (const statement of functionStatements) {
1274
- if (statement.nodeType !== 47 /* ParseNodeType.StatementList */ || statement.statements.length !== 1) {
1283
+ if (statement.nodeType !== 47 /* ParseNodeType.StatementList */ || statement.d.statements.length !== 1) {
1275
1284
  break;
1276
1285
  }
1277
- const simpleStatement = statement.statements[0];
1286
+ const simpleStatement = statement.d.statements[0];
1278
1287
  if (simpleStatement.nodeType === 48 /* ParseNodeType.StringList */) {
1279
1288
  continue;
1280
1289
  }
1281
- if (simpleStatement.nodeType === 43 /* ParseNodeType.Raise */ && simpleStatement.typeExpression) {
1290
+ if (simpleStatement.nodeType === 43 /* ParseNodeType.Raise */ && simpleStatement.d.typeExpression) {
1282
1291
  // Check for a raising about 'NotImplementedError' or a subtype thereof.
1283
- const exceptionType = evaluator.getType(simpleStatement.typeExpression);
1292
+ const exceptionType = evaluator.getType(simpleStatement.d.typeExpression);
1284
1293
  if (exceptionType &&
1285
1294
  (0, types_1.isClass)(exceptionType) &&
1286
1295
  (0, typeUtils_1.derivesFromStdlibClass)(exceptionType, 'NotImplementedError')) {
@@ -1297,10 +1306,10 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
1297
1306
  return false;
1298
1307
  }
1299
1308
  function isAfterNodeReachable(evaluator, functionType) {
1300
- if (!functionType.details.declaration) {
1309
+ if (!functionType.shared.declaration) {
1301
1310
  return true;
1302
1311
  }
1303
- return evaluator.isAfterNodeReachable(functionType.details.declaration.node);
1312
+ return evaluator.isAfterNodeReachable(functionType.shared.declaration.node);
1304
1313
  }
1305
1314
  // Performs a cursory analysis to determine whether the expression
1306
1315
  // corresponds to a context manager object that supports the swallowing
@@ -1326,22 +1335,22 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
1326
1335
  if (cmType && (0, types_1.isClassInstance)(cmType)) {
1327
1336
  const exitMethodName = isAsync ? '__aexit__' : '__exit__';
1328
1337
  const exitType = evaluator.getBoundMagicMethod(cmType, exitMethodName);
1329
- if (exitType && (0, types_1.isFunction)(exitType) && exitType.details.declaredReturnType) {
1330
- let returnType = exitType.details.declaredReturnType;
1338
+ if (exitType && (0, types_1.isFunction)(exitType) && exitType.shared.declaredReturnType) {
1339
+ let returnType = exitType.shared.declaredReturnType;
1331
1340
  // If it's an __aexit__ method, its return type will typically be wrapped
1332
1341
  // in a Coroutine, so we need to extract the return type from the third
1333
1342
  // type argument.
1334
1343
  if (isAsync) {
1335
1344
  if ((0, types_1.isClassInstance)(returnType) &&
1336
1345
  types_1.ClassType.isBuiltIn(returnType, 'Coroutine') &&
1337
- returnType.typeArguments &&
1338
- returnType.typeArguments.length >= 3) {
1339
- returnType = returnType.typeArguments[2];
1346
+ returnType.priv.typeArguments &&
1347
+ returnType.priv.typeArguments.length >= 3) {
1348
+ returnType = returnType.priv.typeArguments[2];
1340
1349
  }
1341
1350
  }
1342
1351
  cmSwallowsExceptions = false;
1343
1352
  if ((0, types_1.isClassInstance)(returnType) && types_1.ClassType.isBuiltIn(returnType, 'bool')) {
1344
- if (returnType.literalValue === undefined || returnType.literalValue === true) {
1353
+ if (returnType.priv.literalValue === undefined || returnType.priv.literalValue === true) {
1345
1354
  cmSwallowsExceptions = true;
1346
1355
  }
1347
1356
  }
@@ -1356,9 +1365,9 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
1356
1365
  return cmSwallowsExceptions;
1357
1366
  }
1358
1367
  function getTypeFromWildcardImport(flowNode, name) {
1359
- const importInfo = (0, analyzerNodeInfo_1.getImportInfo)(flowNode.node.module);
1368
+ const importInfo = (0, analyzerNodeInfo_1.getImportInfo)(flowNode.node.d.module);
1360
1369
  (0, debug_1.assert)(importInfo !== undefined && importInfo.isImportFound);
1361
- (0, debug_1.assert)(flowNode.node.isWildcardImport);
1370
+ (0, debug_1.assert)(flowNode.node.d.isWildcardImport);
1362
1371
  const symbolWithScope = evaluator.lookUpSymbolRecursive(flowNode.node, name, /* honorCodeFlow */ false);
1363
1372
  (0, debug_1.assert)(symbolWithScope !== undefined);
1364
1373
  const decls = symbolWithScope.symbol.getDeclarations();