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

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 (170) 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 +507 -513
  4. package/dist/analyzer/binder.js.map +1 -1
  5. package/dist/analyzer/checker.js +652 -633
  6. package/dist/analyzer/checker.js.map +1 -1
  7. package/dist/analyzer/codeFlowEngine.d.ts +5 -3
  8. package/dist/analyzer/codeFlowEngine.js +143 -122
  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.d.ts +1 -1
  13. package/dist/analyzer/constraintSolver.js +71 -67
  14. package/dist/analyzer/constraintSolver.js.map +1 -1
  15. package/dist/analyzer/constructorTransform.js +22 -22
  16. package/dist/analyzer/constructorTransform.js.map +1 -1
  17. package/dist/analyzer/constructors.js +85 -77
  18. package/dist/analyzer/constructors.js.map +1 -1
  19. package/dist/analyzer/dataClasses.js +113 -176
  20. package/dist/analyzer/dataClasses.js.map +1 -1
  21. package/dist/analyzer/declaration.d.ts +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 +85 -85
  25. package/dist/analyzer/decorators.js.map +1 -1
  26. package/dist/analyzer/enums.js +71 -57
  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.d.ts +4 -4
  38. package/dist/analyzer/operations.js +70 -70
  39. package/dist/analyzer/operations.js.map +1 -1
  40. package/dist/analyzer/packageTypeVerifier.js +66 -62
  41. package/dist/analyzer/packageTypeVerifier.js.map +1 -1
  42. package/dist/analyzer/parameterUtils.d.ts +4 -4
  43. package/dist/analyzer/parameterUtils.js +28 -46
  44. package/dist/analyzer/parameterUtils.js.map +1 -1
  45. package/dist/analyzer/parseTreeUtils.js +268 -269
  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 +195 -147
  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 +78 -147
  54. package/dist/analyzer/properties.js.map +1 -1
  55. package/dist/analyzer/protocols.js +22 -22
  56. package/dist/analyzer/protocols.js.map +1 -1
  57. package/dist/analyzer/sourceFile.d.ts +3 -2
  58. package/dist/analyzer/sourceFile.js +8 -8
  59. package/dist/analyzer/sourceFile.js.map +1 -1
  60. package/dist/analyzer/sourceMapper.js +20 -19
  61. package/dist/analyzer/sourceMapper.js.map +1 -1
  62. package/dist/analyzer/staticExpressions.js +83 -84
  63. package/dist/analyzer/staticExpressions.js.map +1 -1
  64. package/dist/analyzer/testWalker.js +2 -2
  65. package/dist/analyzer/testWalker.js.map +1 -1
  66. package/dist/analyzer/tracePrinter.js +20 -20
  67. package/dist/analyzer/tracePrinter.js.map +1 -1
  68. package/dist/analyzer/typeDocStringUtils.js +25 -25
  69. package/dist/analyzer/typeDocStringUtils.js.map +1 -1
  70. package/dist/analyzer/typeEvaluator.js +2330 -2367
  71. package/dist/analyzer/typeEvaluator.js.map +1 -1
  72. package/dist/analyzer/typeEvaluatorTypes.d.ts +33 -31
  73. package/dist/analyzer/typeEvaluatorTypes.js +48 -41
  74. package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
  75. package/dist/analyzer/typeGuards.js +221 -217
  76. package/dist/analyzer/typeGuards.js.map +1 -1
  77. package/dist/analyzer/typePrinter.js +118 -115
  78. package/dist/analyzer/typePrinter.js.map +1 -1
  79. package/dist/analyzer/typeStubWriter.js +104 -103
  80. package/dist/analyzer/typeStubWriter.js.map +1 -1
  81. package/dist/analyzer/typeUtils.d.ts +26 -9
  82. package/dist/analyzer/typeUtils.js +460 -404
  83. package/dist/analyzer/typeUtils.js.map +1 -1
  84. package/dist/analyzer/typeVarContext.js +8 -8
  85. package/dist/analyzer/typeVarContext.js.map +1 -1
  86. package/dist/analyzer/typeWalker.js +13 -10
  87. package/dist/analyzer/typeWalker.js.map +1 -1
  88. package/dist/analyzer/typedDicts.js +96 -198
  89. package/dist/analyzer/typedDicts.js.map +1 -1
  90. package/dist/analyzer/types.d.ts +147 -103
  91. package/dist/analyzer/types.js +668 -493
  92. package/dist/analyzer/types.js.map +1 -1
  93. package/dist/commands/dumpFileDebugInfoCommand.js +33 -33
  94. package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
  95. package/dist/common/diagnostic.d.ts +14 -0
  96. package/dist/common/diagnostic.js +41 -1
  97. package/dist/common/diagnostic.js.map +1 -1
  98. package/dist/common/diagnosticSink.d.ts +4 -0
  99. package/dist/common/diagnosticSink.js +21 -1
  100. package/dist/common/diagnosticSink.js.map +1 -1
  101. package/dist/common/fileSystem.d.ts +1 -0
  102. package/dist/common/fileSystem.js.map +1 -1
  103. package/dist/common/fullAccessHost.js +6 -4
  104. package/dist/common/fullAccessHost.js.map +1 -1
  105. package/dist/common/realFileSystem.d.ts +1 -0
  106. package/dist/common/realFileSystem.js +4 -0
  107. package/dist/common/realFileSystem.js.map +1 -1
  108. package/dist/common/textEditTracker.js +14 -14
  109. package/dist/common/textEditTracker.js.map +1 -1
  110. package/dist/languageService/autoImporter.js +10 -10
  111. package/dist/languageService/autoImporter.js.map +1 -1
  112. package/dist/languageService/callHierarchyProvider.js +23 -23
  113. package/dist/languageService/callHierarchyProvider.js.map +1 -1
  114. package/dist/languageService/completionProvider.d.ts +1 -1
  115. package/dist/languageService/completionProvider.js +156 -154
  116. package/dist/languageService/completionProvider.js.map +1 -1
  117. package/dist/languageService/definitionProvider.d.ts +1 -1
  118. package/dist/languageService/definitionProvider.js +3 -1
  119. package/dist/languageService/definitionProvider.js.map +1 -1
  120. package/dist/languageService/documentSymbolCollector.js +19 -19
  121. package/dist/languageService/documentSymbolCollector.js.map +1 -1
  122. package/dist/languageService/hoverProvider.js +25 -24
  123. package/dist/languageService/hoverProvider.js.map +1 -1
  124. package/dist/languageService/importSorter.js +8 -8
  125. package/dist/languageService/importSorter.js.map +1 -1
  126. package/dist/languageService/referencesProvider.js +8 -8
  127. package/dist/languageService/referencesProvider.js.map +1 -1
  128. package/dist/languageService/signatureHelpProvider.d.ts +1 -1
  129. package/dist/languageService/signatureHelpProvider.js +6 -6
  130. package/dist/languageService/signatureHelpProvider.js.map +1 -1
  131. package/dist/languageService/symbolIndexer.js +3 -3
  132. package/dist/languageService/symbolIndexer.js.map +1 -1
  133. package/dist/languageService/tooltipUtils.js +13 -13
  134. package/dist/languageService/tooltipUtils.js.map +1 -1
  135. package/dist/localization/localize.d.ts +3 -0
  136. package/dist/localization/localize.js +1 -0
  137. package/dist/localization/localize.js.map +1 -1
  138. package/dist/localization/package.nls.en-us.json +2 -1
  139. package/dist/parser/parseNodes.d.ts +468 -401
  140. package/dist/parser/parseNodes.js +626 -355
  141. package/dist/parser/parseNodes.js.map +1 -1
  142. package/dist/parser/parser.d.ts +1 -0
  143. package/dist/parser/parser.js +322 -297
  144. package/dist/parser/parser.js.map +1 -1
  145. package/dist/pyright.js +265 -5
  146. package/dist/pyright.js.map +1 -1
  147. package/dist/tests/classDeclaration.test.js +14 -14
  148. package/dist/tests/classDeclaration.test.js.map +1 -1
  149. package/dist/tests/fourslash/hover.init.fourslash.js +1 -1
  150. package/dist/tests/fourslash/hover.init.fourslash.js.map +1 -1
  151. package/dist/tests/harness/vfs/filesystem.d.ts +3 -2
  152. package/dist/tests/harness/vfs/filesystem.js +6 -2
  153. package/dist/tests/harness/vfs/filesystem.js.map +1 -1
  154. package/dist/tests/importResolver.test.js +4 -3
  155. package/dist/tests/importResolver.test.js.map +1 -1
  156. package/dist/tests/parseTreeUtils.test.js +5 -5
  157. package/dist/tests/parseTreeUtils.test.js.map +1 -1
  158. package/dist/tests/parser.test.js +8 -8
  159. package/dist/tests/parser.test.js.map +1 -1
  160. package/dist/tests/sourceMapperUtils.test.js +7 -7
  161. package/dist/tests/sourceMapperUtils.test.js.map +1 -1
  162. package/dist/tests/typeEvaluator2.test.js +2 -2
  163. package/dist/tests/typeEvaluator3.test.js +10 -5
  164. package/dist/tests/typeEvaluator3.test.js.map +1 -1
  165. package/dist/tests/typeEvaluator4.test.js +1 -1
  166. package/dist/tests/typeEvaluator7.test.js +2 -2
  167. package/dist/tests/typeEvaluator7.test.js.map +1 -1
  168. package/dist/tests/typePrinter.test.js +14 -39
  169. package/dist/tests/typePrinter.test.js.map +1 -1
  170. 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;
@@ -41,6 +53,7 @@ const enablePrintCallNoReturn = false;
41
53
  const inferNoReturnForUnannotatedFunctions = false;
42
54
  function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
43
55
  const isReachableRecursionSet = new Set();
56
+ const reachabilityCache = new Map();
44
57
  const callIsNoReturnCache = new Map();
45
58
  const isExceptionContextManagerCache = new Map();
46
59
  let flowIncompleteGeneration = 1;
@@ -124,12 +137,7 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
124
137
  : type;
125
138
  flowNodeTypeCache.cache.set(flowNode.id, entry);
126
139
  speculativeTypeTracker.trackEntry(flowNodeTypeCache.cache, flowNode.id);
127
- return {
128
- type,
129
- isIncomplete,
130
- generationCount: flowIncompleteGeneration,
131
- incompleteSubtypes: isIncomplete ? [] : undefined,
132
- };
140
+ return FlowNodeTypeResult.create(type, isIncomplete, flowIncompleteGeneration, isIncomplete ? [] : undefined);
133
141
  }
134
142
  function setIncompleteSubtype(flowNode, index, type, isIncomplete, isPending, evaluationCount) {
135
143
  const cachedEntry = flowNodeTypeCache.cache.get(flowNode.id);
@@ -181,17 +189,13 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
181
189
  }
182
190
  const cachedEntry = flowNodeTypeCache.cache.get(flowNode.id);
183
191
  if (cachedEntry === undefined) {
184
- return { type: undefined, isIncomplete: false };
192
+ return FlowNodeTypeResult.create(/* type */ undefined, /* isIncomplete */ false);
185
193
  }
186
194
  if (!isIncompleteType(cachedEntry)) {
187
- return { type: cachedEntry, isIncomplete: false };
195
+ return FlowNodeTypeResult.create(cachedEntry, /* isIncomplete */ false);
188
196
  }
189
- return {
190
- type: cachedEntry.type,
191
- isIncomplete: true,
192
- incompleteSubtypes: cachedEntry.incompleteSubtypes,
193
- generationCount: cachedEntry.generationCount,
194
- };
197
+ return FlowNodeTypeResult.create(cachedEntry.type,
198
+ /* isIncomplete */ true, cachedEntry.generationCount, cachedEntry.incompleteSubtypes);
195
199
  }
196
200
  function deleteCacheEntry(flowNode) {
197
201
  flowNodeTypeCache.cache.delete(flowNode.id);
@@ -245,18 +249,14 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
245
249
  // If the cached entry is incomplete, we can use it only if nothing
246
250
  // has changed that may cause the previously-reported incomplete type to change.
247
251
  if (cachedEntry.generationCount === flowIncompleteGeneration) {
248
- return {
249
- type: cachedEntry.type ? (0, typeUtils_1.cleanIncompleteUnknown)(cachedEntry.type) : undefined,
250
- isIncomplete: true,
251
- };
252
+ return FlowNodeTypeResult.create(cachedEntry.type ? (0, typeUtils_1.cleanIncompleteUnknown)(cachedEntry.type) : undefined,
253
+ /* isIncomplete */ true);
252
254
  }
253
255
  }
254
256
  // Check for recursion.
255
257
  if (flowNodeTypeCache.pendingNodes.has(curFlowNode.id)) {
256
- return {
257
- type: (_a = cachedEntry === null || cachedEntry === void 0 ? void 0 : cachedEntry.type) !== null && _a !== void 0 ? _a : types_1.UnknownType.create(/* isIncomplete */ true),
258
- isIncomplete: true,
259
- };
258
+ return FlowNodeTypeResult.create((_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
260
  }
261
261
  if (curFlowNode.flags & codeFlowTypes_1.FlowFlags.Unreachable) {
262
262
  // We can get here if there are nodes in a compound logical expression
@@ -311,10 +311,7 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
311
311
  if (flowTypeResult) {
312
312
  if ((0, typeUtils_1.isTypeAliasPlaceholder)(flowTypeResult.type)) {
313
313
  // Don't cache a recursive type alias placeholder.
314
- return {
315
- type: flowTypeResult.type,
316
- isIncomplete: true,
317
- };
314
+ return FlowNodeTypeResult.create(flowTypeResult.type, /* isIncomplete */ true);
318
315
  }
319
316
  else if (reference.nodeType === 35 /* ParseNodeType.MemberAccess */ &&
320
317
  evaluator.isAsymmetricAccessorAssignment(targetNode)) {
@@ -327,16 +324,16 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
327
324
  // be assigning to a TypedDict, which requires narrowing of the expression's
328
325
  // base type.
329
326
  if (targetNode.nodeType === 27 /* ParseNodeType.Index */ &&
330
- (0, parseTreeUtils_1.isMatchingExpression)(reference, targetNode.baseExpression)) {
327
+ (0, parseTreeUtils_1.isMatchingExpression)(reference, targetNode.d.leftExpr)) {
331
328
  if (((_b = targetNode.parent) === null || _b === void 0 ? void 0 : _b.nodeType) === 3 /* ParseNodeType.Assignment */ &&
332
- targetNode.items.length === 1 &&
333
- !targetNode.trailingComma &&
334
- !targetNode.items[0].name &&
335
- targetNode.items[0].argumentCategory === 0 /* ArgumentCategory.Simple */ &&
336
- targetNode.items[0].valueExpression.nodeType === 48 /* ParseNodeType.StringList */ &&
337
- targetNode.items[0].valueExpression.strings.length === 1 &&
338
- targetNode.items[0].valueExpression.strings[0].nodeType === 49 /* ParseNodeType.String */) {
339
- const keyValue = targetNode.items[0].valueExpression.strings[0].value;
329
+ targetNode.d.items.length === 1 &&
330
+ !targetNode.d.trailingComma &&
331
+ !targetNode.d.items[0].d.name &&
332
+ targetNode.d.items[0].d.argCategory === 0 /* ArgumentCategory.Simple */ &&
333
+ targetNode.d.items[0].d.valueExpr.nodeType === 48 /* ParseNodeType.StringList */ &&
334
+ targetNode.d.items[0].d.valueExpr.d.strings.length === 1 &&
335
+ targetNode.d.items[0].d.valueExpr.d.strings[0].nodeType === 49 /* ParseNodeType.String */) {
336
+ const keyValue = targetNode.d.items[0].d.valueExpr.d.strings[0].d.value;
340
337
  const narrowedResult = preventRecursion(assignmentFlowNode, () => {
341
338
  const flowTypeResult = getTypeFromFlowNode(assignmentFlowNode.antecedent);
342
339
  if (flowTypeResult.type) {
@@ -359,10 +356,7 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
359
356
  // a = Foo()
360
357
  // x = a.b
361
358
  // The type of "a.b" can no longer be assumed to be Literal[3].
362
- return {
363
- type: (_c = options === null || options === void 0 ? void 0 : options.typeAtStart) === null || _c === void 0 ? void 0 : _c.type,
364
- isIncomplete: !!((_d = options === null || options === void 0 ? void 0 : options.typeAtStart) === null || _d === void 0 ? void 0 : _d.isIncomplete),
365
- };
359
+ 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));
366
360
  }
367
361
  }
368
362
  curFlowNode = assignmentFlowNode.antecedent;
@@ -450,7 +444,7 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
450
444
  // Make sure the reference type has a declared type. If not,
451
445
  // don't bother trying to infer its type because that would be
452
446
  // too expensive.
453
- const symbolWithScope = evaluator.lookUpSymbolRecursive(conditionalFlowNode.reference, conditionalFlowNode.reference.value,
447
+ const symbolWithScope = evaluator.lookUpSymbolRecursive(conditionalFlowNode.reference, conditionalFlowNode.reference.d.value,
454
448
  /* honorCodeFlow */ false);
455
449
  if (symbolWithScope && symbolWithScope.symbol.hasTypedDeclarations()) {
456
450
  const result = preventRecursion(curFlowNode, () => {
@@ -561,7 +555,7 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
561
555
  if (curFlowNode.flags & codeFlowTypes_1.FlowFlags.WildcardImport) {
562
556
  const wildcardImportFlowNode = curFlowNode;
563
557
  if (reference && reference.nodeType === 38 /* ParseNodeType.Name */) {
564
- const nameValue = reference.value;
558
+ const nameValue = reference.d.value;
565
559
  if (wildcardImportFlowNode.names.some((name) => name === nameValue)) {
566
560
  return preventRecursion(curFlowNode, () => {
567
561
  const type = getTypeFromWildcardImport(wildcardImportFlowNode, nameValue);
@@ -614,10 +608,8 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
614
608
  // If entries have been added for all antecedents and there are pending entries
615
609
  // that have not been evaluated even once, treat it as incomplete. We clean
616
610
  // any incomplete unknowns from the type here to assist with type convergence.
617
- return {
618
- type: cacheEntry.type ? (0, typeUtils_1.cleanIncompleteUnknown)(cacheEntry.type) : undefined,
619
- isIncomplete: true,
620
- };
611
+ return FlowNodeTypeResult.create(cacheEntry.type ? (0, typeUtils_1.cleanIncompleteUnknown)(cacheEntry.type) : undefined,
612
+ /* isIncomplete */ true);
621
613
  }
622
614
  let attemptCount = 0;
623
615
  while (true) {
@@ -704,7 +696,7 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
704
696
  // entry because we'll overwrite a pending evaluation. The type that
705
697
  // we return here doesn't matter as long as it's not undefined.
706
698
  return sawPending
707
- ? { type: types_1.UnknownType.create(), isIncomplete: false }
699
+ ? FlowNodeTypeResult.create(types_1.UnknownType.create(), /* isIncomplete */ false)
708
700
  : setCacheEntry(loopNode, types_1.UnknownType.create(), /* isIncomplete */ false);
709
701
  }
710
702
  let effectiveType = cacheEntry.type;
@@ -741,12 +733,12 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
741
733
  // other incomplete types based on this now-complete type.
742
734
  flowIncompleteGeneration++;
743
735
  }
744
- return { type: effectiveType, isIncomplete: reportIncomplete };
736
+ return FlowNodeTypeResult.create(effectiveType, reportIncomplete);
745
737
  }
746
738
  // If the first antecedent was pending, we skipped all of the other
747
739
  // antecedents, so the type is incomplete.
748
740
  if (firstAntecedentTypeIsPending) {
749
- return { type: effectiveType, isIncomplete: true };
741
+ return FlowNodeTypeResult.create(effectiveType, /* isIncomplete */ true);
750
742
  }
751
743
  return setCacheEntry(loopNode, effectiveType, /* isIncomplete */ false);
752
744
  }
@@ -756,15 +748,12 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
756
748
  function getTypeFromPreFinallyGateFlowNode(preFinallyFlowNode) {
757
749
  // Is the finally gate closed?
758
750
  if (flowNodeTypeCache.closedFinallyGateNodes.has(preFinallyFlowNode.id)) {
759
- return { type: undefined, isIncomplete: false };
751
+ return FlowNodeTypeResult.create(/* type */ undefined, /* isIncomplete */ false);
760
752
  }
761
753
  const flowTypeResult = getTypeFromFlowNode(preFinallyFlowNode.antecedent);
762
754
  // We want to cache the type only if we're evaluating the "gate closed" path.
763
755
  deleteCacheEntry(preFinallyFlowNode);
764
- return {
765
- type: flowTypeResult.type,
766
- isIncomplete: flowTypeResult.isIncomplete,
767
- };
756
+ return FlowNodeTypeResult.create(flowTypeResult.type, flowTypeResult.isIncomplete);
768
757
  }
769
758
  function getTypeFromPostFinallyFlowNode(postFinallyFlowNode) {
770
759
  const wasGateClosed = flowNodeTypeCache.closedFinallyGateNodes.has(postFinallyFlowNode.preFinallyGate.id);
@@ -793,10 +782,7 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
793
782
  // parse nodes that are created after the initial parse
794
783
  // (namely, string literals that are used for forward
795
784
  // referenced types).
796
- return {
797
- type: (_a = options === null || options === void 0 ? void 0 : options.typeAtStart) === null || _a === void 0 ? void 0 : _a.type,
798
- isIncomplete: !!((_b = options === null || options === void 0 ? void 0 : options.typeAtStart) === null || _b === void 0 ? void 0 : _b.isIncomplete),
799
- };
785
+ 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));
800
786
  }
801
787
  return getTypeFromFlowNode(flowNode);
802
788
  }
@@ -814,7 +800,26 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
814
800
  if (enablePrintControlFlowGraph) {
815
801
  printControlFlowGraph(flowNode, /* reference */ undefined, 'isFlowNodeReachable');
816
802
  }
817
- function isFlowNodeReachableRecursive(flowNode, sourceFlowNode, recursionCount = 0) {
803
+ function cacheReachabilityResult(isReachable) {
804
+ // If there is a finally gate set, we will not cache the results
805
+ // because this can affect the reachability.
806
+ if (closedFinallyGateSet.size > 0) {
807
+ return isReachable;
808
+ }
809
+ let cacheEntry = reachabilityCache.get(flowNode.id);
810
+ if (!cacheEntry) {
811
+ cacheEntry = { isReachable: undefined, isReachableFrom: new Map() };
812
+ reachabilityCache.set(flowNode.id, cacheEntry);
813
+ }
814
+ if (!sourceFlowNode) {
815
+ cacheEntry.isReachable = isReachable;
816
+ }
817
+ else {
818
+ cacheEntry.isReachableFrom.set(sourceFlowNode.id, isReachable);
819
+ }
820
+ return isReachable;
821
+ }
822
+ function isFlowNodeReachableRecursive(flowNode, recursionCount = 0) {
818
823
  var _a;
819
824
  // Cut off the recursion at some point to prevent a stack overflow.
820
825
  const maxFlowNodeReachableRecursionCount = 64;
@@ -824,18 +829,33 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
824
829
  recursionCount++;
825
830
  let curFlowNode = flowNode;
826
831
  while (true) {
832
+ // See if we've already cached this result.
833
+ const cacheEntry = reachabilityCache.get(flowNode.id);
834
+ if (cacheEntry !== undefined && closedFinallyGateSet.size === 0) {
835
+ if (!sourceFlowNode) {
836
+ if (cacheEntry.isReachable !== undefined) {
837
+ return cacheEntry.isReachable;
838
+ }
839
+ }
840
+ else {
841
+ const isReachableFrom = cacheEntry.isReachableFrom.get(sourceFlowNode.id);
842
+ if (isReachableFrom !== undefined) {
843
+ return isReachableFrom;
844
+ }
845
+ }
846
+ }
827
847
  // If we've already visited this node, we can assume
828
848
  // it wasn't reachable.
829
849
  if (visitedFlowNodeSet.has(curFlowNode.id)) {
830
- return false;
850
+ return cacheReachabilityResult(false);
831
851
  }
832
852
  // Note that we've been here before.
833
853
  visitedFlowNodeSet.add(curFlowNode.id);
834
854
  if (curFlowNode.flags & codeFlowTypes_1.FlowFlags.Unreachable) {
835
- return false;
855
+ return cacheReachabilityResult(false);
836
856
  }
837
857
  if (curFlowNode === sourceFlowNode) {
838
- return true;
858
+ return cacheReachabilityResult(true);
839
859
  }
840
860
  if (curFlowNode.flags &
841
861
  (codeFlowTypes_1.FlowFlags.VariableAnnotation |
@@ -857,7 +877,7 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
857
877
  // Make sure the reference type has a declared type. If not,
858
878
  // don't bother trying to infer its type because that would be
859
879
  // too expensive.
860
- const symbolWithScope = evaluator.lookUpSymbolRecursive(conditionalFlowNode.reference, conditionalFlowNode.reference.value,
880
+ const symbolWithScope = evaluator.lookUpSymbolRecursive(conditionalFlowNode.reference, conditionalFlowNode.reference.d.value,
861
881
  /* honorCodeFlow */ false);
862
882
  if (symbolWithScope && symbolWithScope.symbol.hasTypedDeclarations()) {
863
883
  let isUnreachable = false;
@@ -871,7 +891,7 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
871
891
  }
872
892
  }
873
893
  if (isUnreachable) {
874
- return false;
894
+ return cacheReachabilityResult(false);
875
895
  }
876
896
  }
877
897
  }
@@ -884,7 +904,7 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
884
904
  // it always raises an exception or otherwise doesn't return,
885
905
  // so we can assume that the code before this is unreachable.
886
906
  if (!ignoreNoReturn && isCallNoReturn(evaluator, callFlowNode)) {
887
- return false;
907
+ return cacheReachabilityResult(false);
888
908
  }
889
909
  curFlowNode = callFlowNode.antecedent;
890
910
  continue;
@@ -895,26 +915,26 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
895
915
  // suppression. If not, none of its antecedents are reachable.
896
916
  const contextMgrNode = curFlowNode;
897
917
  if (!contextMgrNode.expressions.some((expr) => isExceptionContextManager(evaluator, expr, contextMgrNode.isAsync))) {
898
- return false;
918
+ return cacheReachabilityResult(false);
899
919
  }
900
920
  }
901
921
  const labelNode = curFlowNode;
902
922
  for (const antecedent of labelNode.antecedents) {
903
- if (isFlowNodeReachableRecursive(antecedent, sourceFlowNode, recursionCount)) {
904
- return true;
923
+ if (isFlowNodeReachableRecursive(antecedent, recursionCount)) {
924
+ return cacheReachabilityResult(true);
905
925
  }
906
926
  }
907
- return false;
927
+ return cacheReachabilityResult(false);
908
928
  }
909
929
  if (curFlowNode.flags & codeFlowTypes_1.FlowFlags.Start) {
910
930
  // If we hit the start but were looking for a particular source flow
911
931
  // node, return false. Otherwise, the start is what we're looking for.
912
- return sourceFlowNode ? false : true;
932
+ return cacheReachabilityResult(sourceFlowNode ? false : true);
913
933
  }
914
934
  if (curFlowNode.flags & codeFlowTypes_1.FlowFlags.PreFinallyGate) {
915
935
  const preFinallyFlowNode = curFlowNode;
916
936
  if (closedFinallyGateSet.has(preFinallyFlowNode.id)) {
917
- return false;
937
+ return cacheReachabilityResult(false);
918
938
  }
919
939
  curFlowNode = preFinallyFlowNode.antecedent;
920
940
  continue;
@@ -924,7 +944,7 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
924
944
  const wasGateClosed = closedFinallyGateSet.has(postFinallyFlowNode.preFinallyGate.id);
925
945
  try {
926
946
  closedFinallyGateSet.add(postFinallyFlowNode.preFinallyGate.id);
927
- return isFlowNodeReachableRecursive(postFinallyFlowNode.antecedent, sourceFlowNode, recursionCount);
947
+ return cacheReachabilityResult(isFlowNodeReachableRecursive(postFinallyFlowNode.antecedent, recursionCount));
928
948
  }
929
949
  finally {
930
950
  if (!wasGateClosed) {
@@ -934,7 +954,7 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
934
954
  }
935
955
  // We shouldn't get here.
936
956
  (0, debug_1.fail)('Unexpected flow node flags');
937
- return false;
957
+ return cacheReachabilityResult(false);
938
958
  }
939
959
  }
940
960
  // Protect against infinite recursion.
@@ -943,7 +963,7 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
943
963
  }
944
964
  isReachableRecursionSet.add(flowNode.id);
945
965
  try {
946
- return isFlowNodeReachableRecursive(flowNode, sourceFlowNode);
966
+ return isFlowNodeReachableRecursive(flowNode);
947
967
  }
948
968
  finally {
949
969
  isReachableRecursionSet.delete(flowNode.id);
@@ -953,13 +973,13 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
953
973
  // can be narrowed to one of its constrained types based on isinstance type
954
974
  // guard checks.
955
975
  function narrowConstrainedTypeVar(flowNode, typeVar) {
956
- (0, debug_1.assert)(!typeVar.details.isParamSpec);
957
- (0, debug_1.assert)(!typeVar.details.isVariadic);
958
- (0, debug_1.assert)(!typeVar.details.boundType);
959
- (0, debug_1.assert)(typeVar.details.constraints.length > 0);
976
+ (0, debug_1.assert)(!typeVar.shared.isParamSpec);
977
+ (0, debug_1.assert)(!typeVar.shared.isVariadic);
978
+ (0, debug_1.assert)(!typeVar.shared.boundType);
979
+ (0, debug_1.assert)(typeVar.shared.constraints.length > 0);
960
980
  const visitedFlowNodeMap = new Set();
961
981
  const startingConstraints = [];
962
- for (const constraint of typeVar.details.constraints) {
982
+ for (const constraint of typeVar.shared.constraints) {
963
983
  if ((0, types_1.isClassInstance)(constraint)) {
964
984
  startingConstraints.push(constraint);
965
985
  }
@@ -998,12 +1018,12 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
998
1018
  if (narrowForPatternFlowNode.statement.nodeType === 64 /* ParseNodeType.Case */) {
999
1019
  const subjectType = evaluator.getTypeOfExpression(narrowForPatternFlowNode.subjectExpression).type;
1000
1020
  if (isCompatibleWithConstrainedTypeVar(subjectType, typeVar)) {
1001
- const patternNode = narrowForPatternFlowNode.statement.pattern;
1021
+ const patternNode = narrowForPatternFlowNode.statement.d.pattern;
1002
1022
  if (patternNode.nodeType === 66 /* ParseNodeType.PatternAs */ &&
1003
- patternNode.orPatterns.length === 1 &&
1004
- patternNode.orPatterns[0].nodeType === 68 /* ParseNodeType.PatternClass */) {
1005
- const classPatternNode = patternNode.orPatterns[0];
1006
- const classType = evaluator.getTypeOfExpression(classPatternNode.className, 2 /* EvaluatorFlags.CallBaseDefaults */).type;
1023
+ patternNode.d.orPatterns.length === 1 &&
1024
+ patternNode.d.orPatterns[0].nodeType === 68 /* ParseNodeType.PatternClass */) {
1025
+ const classPatternNode = patternNode.d.orPatterns[0];
1026
+ const classType = evaluator.getTypeOfExpression(classPatternNode.d.className, 2 /* EvalFlags.CallBaseDefaults */).type;
1007
1027
  if ((0, types_1.isInstantiableClass)(classType)) {
1008
1028
  const priorRemainingConstraints = narrowConstrainedTypeVarRecursive(narrowForPatternFlowNode.antecedent, typeVar);
1009
1029
  return priorRemainingConstraints.filter((subtype) => types_1.ClassType.isSameGenericClass(subtype, classType));
@@ -1020,23 +1040,23 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
1020
1040
  const testExpression = conditionFlowNode.expression;
1021
1041
  const isPositiveTest = (curFlowNode.flags & codeFlowTypes_1.FlowFlags.TrueCondition) !== 0;
1022
1042
  if (testExpression.nodeType === 9 /* ParseNodeType.Call */ &&
1023
- testExpression.leftExpression.nodeType === 38 /* ParseNodeType.Name */ &&
1024
- testExpression.leftExpression.value === 'isinstance' &&
1025
- testExpression.arguments.length === 2) {
1026
- const arg0Expr = testExpression.arguments[0].valueExpression;
1043
+ testExpression.d.leftExpr.nodeType === 38 /* ParseNodeType.Name */ &&
1044
+ testExpression.d.leftExpr.d.value === 'isinstance' &&
1045
+ testExpression.d.args.length === 2) {
1046
+ const arg0Expr = testExpression.d.args[0].d.valueExpr;
1027
1047
  const arg0Type = evaluator.getTypeOfExpression(arg0Expr).type;
1028
1048
  if (isCompatibleWithConstrainedTypeVar(arg0Type, typeVar)) {
1029
1049
  // Prevent infinite recursion by noting that we've been here before.
1030
1050
  visitedFlowNodeMap.add(curFlowNode.id);
1031
1051
  const priorRemainingConstraints = narrowConstrainedTypeVarRecursive(conditionFlowNode.antecedent, typeVar);
1032
1052
  visitedFlowNodeMap.delete(curFlowNode.id);
1033
- const arg1Expr = testExpression.arguments[1].valueExpression;
1034
- const arg1Type = evaluator.getTypeOfExpression(arg1Expr, 512 /* EvaluatorFlags.AllowMissingTypeArgs */ |
1035
- 8 /* EvaluatorFlags.EvaluateStringLiteralAsType */ |
1036
- 32 /* EvaluatorFlags.DisallowParamSpec */ |
1037
- 64 /* EvaluatorFlags.DisallowTypeVarTuple */ |
1038
- 16 /* EvaluatorFlags.DisallowFinal */ |
1039
- 2 /* EvaluatorFlags.DoNotSpecialize */).type;
1053
+ const arg1Expr = testExpression.d.args[1].d.valueExpr;
1054
+ const arg1Type = evaluator.getTypeOfExpression(arg1Expr, 512 /* EvalFlags.AllowMissingTypeArgs */ |
1055
+ 8 /* EvalFlags.StrLiteralAsType */ |
1056
+ 32 /* EvalFlags.NoParamSpec */ |
1057
+ 64 /* EvalFlags.NoTypeVarTuple */ |
1058
+ 16 /* EvalFlags.NoFinal */ |
1059
+ 2 /* EvalFlags.NoSpecialize */).type;
1040
1060
  if ((0, types_1.isInstantiableClass)(arg1Type)) {
1041
1061
  return priorRemainingConstraints.filter((subtype) => {
1042
1062
  if (types_1.ClassType.isSameGenericClass(subtype, arg1Type)) {
@@ -1083,14 +1103,15 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
1083
1103
  function isCompatibleWithConstrainedTypeVar(type, typeVar) {
1084
1104
  let isCompatible = true;
1085
1105
  (0, typeUtils_1.doForEachSubtype)(type, (subtype) => {
1106
+ var _a;
1086
1107
  if ((0, types_1.isTypeVar)(subtype)) {
1087
1108
  if (!(0, types_1.isTypeSame)(subtype, typeVar)) {
1088
1109
  isCompatible = false;
1089
1110
  }
1090
1111
  }
1091
- else if (subtype.condition) {
1092
- if (!subtype.condition.some((condition) => condition.typeVar.details.constraints.length > 0 &&
1093
- condition.typeVar.nameWithScope === typeVar.nameWithScope)) {
1112
+ else if ((_a = subtype.props) === null || _a === void 0 ? void 0 : _a.condition) {
1113
+ if (!subtype.props.condition.some((condition) => condition.typeVar.shared.constraints.length > 0 &&
1114
+ condition.typeVar.priv.nameWithScope === typeVar.priv.nameWithScope)) {
1094
1115
  isCompatible = false;
1095
1116
  }
1096
1117
  }
@@ -1121,7 +1142,7 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
1121
1142
  }
1122
1143
  // Don't attempt to evaluate a lambda call. We need to evaluate these in the
1123
1144
  // context of its arguments.
1124
- if (node.leftExpression.nodeType === 33 /* ParseNodeType.Lambda */) {
1145
+ if (node.d.leftExpr.nodeType === 33 /* ParseNodeType.Lambda */) {
1125
1146
  return false;
1126
1147
  }
1127
1148
  // Initially set to false to avoid recursion.
@@ -1131,7 +1152,7 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
1131
1152
  let noReturnTypeCount = 0;
1132
1153
  let subtypeCount = 0;
1133
1154
  // Evaluate the call base type.
1134
- const callTypeResult = evaluator.getTypeOfExpression(node.leftExpression, 2 /* EvaluatorFlags.CallBaseDefaults */);
1155
+ const callTypeResult = evaluator.getTypeOfExpression(node.d.leftExpr, 2 /* EvalFlags.CallBaseDefaults */);
1135
1156
  const callType = callTypeResult.type;
1136
1157
  (0, typeUtils_1.doForEachSubtype)(callType, (callSubtype) => {
1137
1158
  var _a;
@@ -1182,7 +1203,7 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
1182
1203
  else {
1183
1204
  // Perform a more complete evaluation to determine whether
1184
1205
  // the applicable overload returns a NoReturn.
1185
- const callResult = evaluator.validateOverloadedFunctionArguments(node, node.arguments, { type: callSubtype, isIncomplete: callTypeResult.isIncomplete },
1206
+ const callResult = evaluator.validateOverloadedFunctionArguments(node, node.d.args.map((arg) => (0, typeUtils_1.convertArgumentNodeToFunctionArgument)(arg)), { type: callSubtype, isIncomplete: callTypeResult.isIncomplete },
1186
1207
  /* typeVarContext */ undefined,
1187
1208
  /* skipUnknownArgCheck */ false,
1188
1209
  /* inferenceContext */ undefined,
@@ -1208,13 +1229,13 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
1208
1229
  }
1209
1230
  }
1210
1231
  function isFunctionNoReturn(functionType, isCallAwaited) {
1211
- const returnType = functionType.details.declaredReturnType;
1232
+ const returnType = functionType.shared.declaredReturnType;
1212
1233
  if (returnType) {
1213
1234
  if ((0, types_1.isClassInstance)(returnType) &&
1214
1235
  types_1.ClassType.isBuiltIn(returnType, 'Coroutine') &&
1215
- returnType.typeArguments &&
1216
- returnType.typeArguments.length >= 3) {
1217
- if ((0, types_1.isNever)(returnType.typeArguments[2]) && isCallAwaited) {
1236
+ returnType.priv.typeArguments &&
1237
+ returnType.priv.typeArguments.length >= 3) {
1238
+ if ((0, types_1.isNever)(returnType.priv.typeArguments[2]) && isCallAwaited) {
1218
1239
  return true;
1219
1240
  }
1220
1241
  }
@@ -1223,29 +1244,29 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
1223
1244
  else if (!inferNoReturnForUnannotatedFunctions) {
1224
1245
  return false;
1225
1246
  }
1226
- else if (functionType.details.declaration) {
1247
+ else if (functionType.shared.declaration) {
1227
1248
  // If the function is a generator (i.e. it has yield statements)
1228
1249
  // then it is not a "no return" call. Also, don't infer a "no
1229
1250
  // return" type for abstract methods.
1230
- if (!functionType.details.declaration.isGenerator &&
1251
+ if (!functionType.shared.declaration.isGenerator &&
1231
1252
  !types_1.FunctionType.isAbstractMethod(functionType) &&
1232
1253
  !types_1.FunctionType.isStubDefinition(functionType) &&
1233
1254
  !types_1.FunctionType.isPyTypedDefinition(functionType)) {
1234
1255
  // Check specifically for a common idiom where the only statement
1235
1256
  // (other than a possible docstring) is a "raise NotImplementedError".
1236
- const functionStatements = functionType.details.declaration.node.suite.statements;
1257
+ const functionStatements = functionType.shared.declaration.node.d.suite.d.statements;
1237
1258
  let foundRaiseNotImplemented = false;
1238
1259
  for (const statement of functionStatements) {
1239
- if (statement.nodeType !== 47 /* ParseNodeType.StatementList */ || statement.statements.length !== 1) {
1260
+ if (statement.nodeType !== 47 /* ParseNodeType.StatementList */ || statement.d.statements.length !== 1) {
1240
1261
  break;
1241
1262
  }
1242
- const simpleStatement = statement.statements[0];
1263
+ const simpleStatement = statement.d.statements[0];
1243
1264
  if (simpleStatement.nodeType === 48 /* ParseNodeType.StringList */) {
1244
1265
  continue;
1245
1266
  }
1246
- if (simpleStatement.nodeType === 43 /* ParseNodeType.Raise */ && simpleStatement.typeExpression) {
1267
+ if (simpleStatement.nodeType === 43 /* ParseNodeType.Raise */ && simpleStatement.d.typeExpression) {
1247
1268
  // Check for a raising about 'NotImplementedError' or a subtype thereof.
1248
- const exceptionType = evaluator.getType(simpleStatement.typeExpression);
1269
+ const exceptionType = evaluator.getType(simpleStatement.d.typeExpression);
1249
1270
  if (exceptionType &&
1250
1271
  (0, types_1.isClass)(exceptionType) &&
1251
1272
  (0, typeUtils_1.derivesFromStdlibClass)(exceptionType, 'NotImplementedError')) {
@@ -1262,10 +1283,10 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
1262
1283
  return false;
1263
1284
  }
1264
1285
  function isAfterNodeReachable(evaluator, functionType) {
1265
- if (!functionType.details.declaration) {
1286
+ if (!functionType.shared.declaration) {
1266
1287
  return true;
1267
1288
  }
1268
- return evaluator.isAfterNodeReachable(functionType.details.declaration.node);
1289
+ return evaluator.isAfterNodeReachable(functionType.shared.declaration.node);
1269
1290
  }
1270
1291
  // Performs a cursory analysis to determine whether the expression
1271
1292
  // corresponds to a context manager object that supports the swallowing
@@ -1291,22 +1312,22 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
1291
1312
  if (cmType && (0, types_1.isClassInstance)(cmType)) {
1292
1313
  const exitMethodName = isAsync ? '__aexit__' : '__exit__';
1293
1314
  const exitType = evaluator.getBoundMagicMethod(cmType, exitMethodName);
1294
- if (exitType && (0, types_1.isFunction)(exitType) && exitType.details.declaredReturnType) {
1295
- let returnType = exitType.details.declaredReturnType;
1315
+ if (exitType && (0, types_1.isFunction)(exitType) && exitType.shared.declaredReturnType) {
1316
+ let returnType = exitType.shared.declaredReturnType;
1296
1317
  // If it's an __aexit__ method, its return type will typically be wrapped
1297
1318
  // in a Coroutine, so we need to extract the return type from the third
1298
1319
  // type argument.
1299
1320
  if (isAsync) {
1300
1321
  if ((0, types_1.isClassInstance)(returnType) &&
1301
1322
  types_1.ClassType.isBuiltIn(returnType, 'Coroutine') &&
1302
- returnType.typeArguments &&
1303
- returnType.typeArguments.length >= 3) {
1304
- returnType = returnType.typeArguments[2];
1323
+ returnType.priv.typeArguments &&
1324
+ returnType.priv.typeArguments.length >= 3) {
1325
+ returnType = returnType.priv.typeArguments[2];
1305
1326
  }
1306
1327
  }
1307
1328
  cmSwallowsExceptions = false;
1308
1329
  if ((0, types_1.isClassInstance)(returnType) && types_1.ClassType.isBuiltIn(returnType, 'bool')) {
1309
- if (returnType.literalValue === undefined || returnType.literalValue === true) {
1330
+ if (returnType.priv.literalValue === undefined || returnType.priv.literalValue === true) {
1310
1331
  cmSwallowsExceptions = true;
1311
1332
  }
1312
1333
  }
@@ -1321,9 +1342,9 @@ function getCodeFlowEngine(evaluator, speculativeTypeTracker) {
1321
1342
  return cmSwallowsExceptions;
1322
1343
  }
1323
1344
  function getTypeFromWildcardImport(flowNode, name) {
1324
- const importInfo = (0, analyzerNodeInfo_1.getImportInfo)(flowNode.node.module);
1345
+ const importInfo = (0, analyzerNodeInfo_1.getImportInfo)(flowNode.node.d.module);
1325
1346
  (0, debug_1.assert)(importInfo !== undefined && importInfo.isImportFound);
1326
- (0, debug_1.assert)(flowNode.node.isWildcardImport);
1347
+ (0, debug_1.assert)(flowNode.node.d.isWildcardImport);
1327
1348
  const symbolWithScope = evaluator.lookUpSymbolRecursive(flowNode.node, name, /* honorCodeFlow */ false);
1328
1349
  (0, debug_1.assert)(symbolWithScope !== undefined);
1329
1350
  const decls = symbolWithScope.symbol.getDeclarations();