@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
@@ -8,7 +8,8 @@
8
8
  * Representation of types used during type analysis within Python.
9
9
  */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.isSameWithoutLiteralValue = exports.combineTypes = exports.findSubtype = exports.removeFromUnion = exports.removeUnbound = exports.removeUnknownFromUnion = exports.isTypeSame = exports.getTypeAliasInfo = exports.isOverloadedFunction = exports.isFunction = exports.isParamSpec = exports.isUnpacked = exports.isUnpackedClass = exports.isUnpackedVariadicTypeVar = exports.isVariadicTypeVar = exports.isTypeVar = exports.isModule = exports.isClassInstance = exports.isInstantiableClass = exports.isClass = exports.isPossiblyUnbound = exports.isUnion = exports.isUnbound = exports.isAnyOrUnknown = exports.isUnknown = exports.isAny = exports.isNever = exports.TypeVarType = exports.TypeVarScopeType = exports.Variance = exports.UnionType = exports.TypeCondition = exports.AnyType = exports.NeverType = exports.OverloadedFunctionType = exports.FunctionType = exports.FunctionTypeFlags = exports.isKeywordOnlySeparator = exports.isPositionOnlySeparator = exports.ClassType = exports.ClassTypeFlags = exports.ModuleType = exports.UnknownType = exports.UnboundType = exports.TypeBase = exports.maxTypeRecursionCount = exports.EnumLiteral = exports.InScopePlaceholderScopeId = exports.TypeFlags = exports.TypeCategory = void 0;
11
+ exports.findSubtype = exports.removeFromUnion = exports.removeUnbound = exports.removeUnknownFromUnion = exports.isTypeSame = exports.getTypeAliasInfo = exports.isOverloadedFunction = exports.isFunction = exports.isParamSpec = exports.isUnpacked = exports.isUnpackedClass = exports.isUnpackedVariadicTypeVar = exports.isVariadicTypeVar = exports.isTypeVar = exports.isModule = exports.isClassInstance = exports.isInstantiableClass = exports.isClass = exports.isPossiblyUnbound = exports.isUnion = exports.isUnbound = exports.isAnyOrUnknown = exports.isUnknown = exports.isAny = exports.isNever = exports.TypeVarType = exports.TypeVarScopeType = exports.Variance = exports.UnionType = exports.TypeCondition = exports.AnyType = exports.NeverType = exports.OverloadedFunctionType = exports.FunctionType = exports.FunctionTypeFlags = exports.isKeywordOnlySeparator = exports.isPositionOnlySeparator = exports.FunctionParam = exports.FunctionParamFlags = exports.ClassType = exports.ClassTypeFlags = exports.ModuleType = exports.UnknownType = exports.UnboundType = exports.TypeBase = exports.maxTypeRecursionCount = exports.EnumLiteral = exports.InScopePlaceholderScopeId = exports.TypeFlags = exports.TypeCategory = void 0;
12
+ exports.isSameWithoutLiteralValue = exports.combineTypes = void 0;
12
13
  const debug_1 = require("../common/debug");
13
14
  var TypeCategory;
14
15
  (function (TypeCategory) {
@@ -46,6 +47,12 @@ var TypeFlags;
46
47
  TypeFlags[TypeFlags["Instantiable"] = 1] = "Instantiable";
47
48
  // This type refers to something that has been instantiated.
48
49
  TypeFlags[TypeFlags["Instance"] = 2] = "Instance";
50
+ // This type is inferred within a py.typed source file and could be
51
+ // inferred differently by other type checkers.
52
+ TypeFlags[TypeFlags["Ambiguous"] = 4] = "Ambiguous";
53
+ // This mask indicates which flags should be considered significant
54
+ // when comparing two types for equivalence.
55
+ TypeFlags[TypeFlags["TypeCompatibilityMask"] = 3] = "TypeCompatibilityMask";
49
56
  })(TypeFlags || (exports.TypeFlags = TypeFlags = {}));
50
57
  exports.InScopePlaceholderScopeId = '-';
51
58
  class EnumLiteral {
@@ -79,42 +86,69 @@ var TypeBase;
79
86
  }
80
87
  TypeBase.isInstance = isInstance;
81
88
  function isAmbiguous(type) {
82
- return !!type.isAmbiguous;
89
+ return (type.flags & 4 /* TypeFlags.Ambiguous */) !== 0;
83
90
  }
84
91
  TypeBase.isAmbiguous = isAmbiguous;
92
+ function addProps(type) {
93
+ if (!type.props) {
94
+ type.props = {
95
+ instantiableDepth: undefined,
96
+ specialForm: undefined,
97
+ typeAliasInfo: undefined,
98
+ condition: undefined,
99
+ };
100
+ }
101
+ return type.props;
102
+ }
103
+ TypeBase.addProps = addProps;
104
+ function setSpecialForm(type, specialForm) {
105
+ TypeBase.addProps(type).specialForm = specialForm;
106
+ }
107
+ TypeBase.setSpecialForm = setSpecialForm;
108
+ function setInstantiableDepth(type, depth) {
109
+ TypeBase.addProps(type).instantiableDepth = depth;
110
+ }
111
+ TypeBase.setInstantiableDepth = setInstantiableDepth;
112
+ function setTypeAliasInfo(type, typeAliasInfo) {
113
+ TypeBase.addProps(type).typeAliasInfo = typeAliasInfo;
114
+ }
115
+ TypeBase.setTypeAliasInfo = setTypeAliasInfo;
116
+ function setCondition(type, condition) {
117
+ TypeBase.addProps(type).condition = condition;
118
+ }
119
+ TypeBase.setCondition = setCondition;
85
120
  function cloneType(type) {
86
121
  const clone = { ...type };
87
- delete clone.cached;
122
+ if (type.props) {
123
+ clone.props = { ...type.props };
124
+ }
125
+ if (type.priv) {
126
+ clone.priv = { ...type.priv };
127
+ }
128
+ clone.cached = undefined;
88
129
  return clone;
89
130
  }
90
131
  TypeBase.cloneType = cloneType;
91
132
  function cloneAsSpecialForm(type, specialForm) {
92
- const clone = { ...type };
93
- delete clone.cached;
94
- if (specialForm) {
95
- clone.specialForm = specialForm;
96
- }
97
- else {
98
- delete clone.specialForm;
99
- }
133
+ const clone = TypeBase.cloneType(type);
134
+ TypeBase.setSpecialForm(clone, specialForm);
100
135
  return clone;
101
136
  }
102
137
  TypeBase.cloneAsSpecialForm = cloneAsSpecialForm;
103
138
  function cloneTypeAsInstance(type, cache) {
139
+ var _a;
104
140
  (0, debug_1.assert)(TypeBase.isInstantiable(type));
105
141
  const newInstance = TypeBase.cloneType(type);
106
- if (newInstance.instantiableNestingLevel === undefined) {
142
+ const depth = (_a = newInstance.props) === null || _a === void 0 ? void 0 : _a.instantiableDepth;
143
+ if (depth === undefined) {
107
144
  newInstance.flags &= ~1 /* TypeFlags.Instantiable */;
108
145
  newInstance.flags |= 2 /* TypeFlags.Instance */;
109
- delete newInstance.instantiableNestingLevel;
146
+ }
147
+ else if (depth <= 1) {
148
+ TypeBase.setInstantiableDepth(newInstance, undefined);
110
149
  }
111
150
  else {
112
- if (newInstance.instantiableNestingLevel === 1) {
113
- delete newInstance.instantiableNestingLevel;
114
- }
115
- else {
116
- newInstance.instantiableNestingLevel--;
117
- }
151
+ TypeBase.setInstantiableDepth(newInstance, depth - 1);
118
152
  }
119
153
  // Should we cache it for next time?
120
154
  if (cache) {
@@ -127,18 +161,21 @@ var TypeBase;
127
161
  }
128
162
  TypeBase.cloneTypeAsInstance = cloneTypeAsInstance;
129
163
  function cloneTypeAsInstantiable(type, cache) {
164
+ var _a, _b;
130
165
  const newInstance = TypeBase.cloneType(type);
131
166
  if (TypeBase.isInstance(type)) {
132
167
  newInstance.flags &= ~2 /* TypeFlags.Instance */;
133
168
  newInstance.flags |= 1 /* TypeFlags.Instantiable */;
134
169
  }
135
170
  else {
136
- newInstance.instantiableNestingLevel =
137
- newInstance.instantiableNestingLevel === undefined ? 1 : newInstance.instantiableNestingLevel;
171
+ const oldDepth = (_a = type.props) === null || _a === void 0 ? void 0 : _a.instantiableDepth;
172
+ TypeBase.setInstantiableDepth(newInstance, oldDepth === undefined ? 1 : oldDepth + 1);
138
173
  }
139
174
  // Remove type alias information because the type will no longer match
140
175
  // that of the type alias definition.
141
- delete newInstance.typeAliasInfo;
176
+ if ((_b = newInstance.props) === null || _b === void 0 ? void 0 : _b.typeAliasInfo) {
177
+ TypeBase.setTypeAliasInfo(newInstance, undefined);
178
+ }
142
179
  // Should we cache it for next time?
143
180
  if (cache) {
144
181
  if (!type.cached) {
@@ -151,36 +188,38 @@ var TypeBase;
151
188
  TypeBase.cloneTypeAsInstantiable = cloneTypeAsInstantiable;
152
189
  function cloneForTypeAlias(type, name, fullName, moduleName, fileUri, typeVarScopeId, isPep695Syntax, typeParams, typeArgs) {
153
190
  const typeClone = cloneType(type);
154
- typeClone.typeAliasInfo = {
191
+ TypeBase.setTypeAliasInfo(typeClone, {
155
192
  name,
156
193
  fullName,
157
194
  moduleName,
158
195
  fileUri,
159
- typeParameters: typeParams,
160
- typeArguments: typeArgs,
161
196
  typeVarScopeId,
162
197
  isPep695Syntax,
163
- };
198
+ typeParameters: typeParams,
199
+ usageVariance: undefined,
200
+ typeArguments: typeArgs,
201
+ });
164
202
  return typeClone;
165
203
  }
166
204
  TypeBase.cloneForTypeAlias = cloneForTypeAlias;
167
205
  function cloneForCondition(type, condition) {
206
+ var _a;
168
207
  // Handle the common case where there are no conditions. In this case,
169
208
  // cloning isn't necessary.
170
- if (type.condition === undefined && condition === undefined) {
209
+ if (((_a = type.props) === null || _a === void 0 ? void 0 : _a.condition) === undefined && condition === undefined) {
171
210
  return type;
172
211
  }
173
212
  const typeClone = cloneType(type);
174
- typeClone.condition = condition;
213
+ TypeBase.setCondition(typeClone, condition);
175
214
  return typeClone;
176
215
  }
177
216
  TypeBase.cloneForCondition = cloneForCondition;
178
217
  function cloneForAmbiguousType(type) {
179
- if (type.isAmbiguous) {
218
+ if (TypeBase.isAmbiguous(type)) {
180
219
  return type;
181
220
  }
182
221
  const typeClone = cloneType(type);
183
- typeClone.isAmbiguous = true;
222
+ typeClone.flags |= 4 /* TypeFlags.Ambiguous */;
184
223
  return typeClone;
185
224
  }
186
225
  TypeBase.cloneForAmbiguousType = cloneForAmbiguousType;
@@ -190,6 +229,10 @@ var UnboundType;
190
229
  const _instance = {
191
230
  category: 0 /* TypeCategory.Unbound */,
192
231
  flags: 1 /* TypeFlags.Instantiable */ | 2 /* TypeFlags.Instance */,
232
+ props: undefined,
233
+ cached: undefined,
234
+ shared: undefined,
235
+ priv: undefined,
193
236
  };
194
237
  function create() {
195
238
  // All Unbound objects are the same, so use a shared instance.
@@ -197,8 +240,9 @@ var UnboundType;
197
240
  }
198
241
  UnboundType.create = create;
199
242
  function convertToInstance(type) {
243
+ var _a;
200
244
  // Remove the "special form" if present. Otherwise return the existing type.
201
- return type.specialForm ? UnboundType.create() : type;
245
+ return ((_a = type.props) === null || _a === void 0 ? void 0 : _a.specialForm) ? UnboundType.create() : type;
202
246
  }
203
247
  UnboundType.convertToInstance = convertToInstance;
204
248
  })(UnboundType || (exports.UnboundType = UnboundType = {}));
@@ -207,12 +251,24 @@ var UnknownType;
207
251
  const _instance = {
208
252
  category: 1 /* TypeCategory.Unknown */,
209
253
  flags: 1 /* TypeFlags.Instantiable */ | 2 /* TypeFlags.Instance */,
210
- isIncomplete: false,
254
+ props: undefined,
255
+ cached: undefined,
256
+ shared: undefined,
257
+ priv: {
258
+ isIncomplete: false,
259
+ possibleType: undefined,
260
+ },
211
261
  };
212
262
  const _incompleteInstance = {
213
263
  category: 1 /* TypeCategory.Unknown */,
214
264
  flags: 1 /* TypeFlags.Instantiable */ | 2 /* TypeFlags.Instance */,
215
- isIncomplete: true,
265
+ props: undefined,
266
+ cached: undefined,
267
+ shared: undefined,
268
+ priv: {
269
+ isIncomplete: true,
270
+ possibleType: undefined,
271
+ },
216
272
  };
217
273
  function create(isIncomplete = false) {
218
274
  return isIncomplete ? _incompleteInstance : _instance;
@@ -222,15 +278,21 @@ var UnknownType;
222
278
  const unknownWithPossibleType = {
223
279
  category: 1 /* TypeCategory.Unknown */,
224
280
  flags: 1 /* TypeFlags.Instantiable */ | 2 /* TypeFlags.Instance */,
225
- isIncomplete,
226
- possibleType,
281
+ props: undefined,
282
+ cached: undefined,
283
+ shared: undefined,
284
+ priv: {
285
+ isIncomplete,
286
+ possibleType,
287
+ },
227
288
  };
228
289
  return unknownWithPossibleType;
229
290
  }
230
291
  UnknownType.createPossibleType = createPossibleType;
231
292
  function convertToInstance(type) {
293
+ var _a;
232
294
  // Remove the "special form" if present. Otherwise return the existing type.
233
- return type.specialForm ? UnknownType.create(type.isIncomplete) : type;
295
+ return ((_a = type.props) === null || _a === void 0 ? void 0 : _a.specialForm) ? UnknownType.create(type.priv.isIncomplete) : type;
234
296
  }
235
297
  UnknownType.convertToInstance = convertToInstance;
236
298
  })(UnknownType || (exports.UnknownType = UnknownType = {}));
@@ -239,11 +301,18 @@ var ModuleType;
239
301
  function create(moduleName, fileUri, symbolTable) {
240
302
  const newModuleType = {
241
303
  category: 7 /* TypeCategory.Module */,
242
- fields: symbolTable || new Map(),
243
- loaderFields: new Map(),
244
304
  flags: 1 /* TypeFlags.Instantiable */ | 1 /* TypeFlags.Instantiable */,
245
- moduleName,
246
- fileUri,
305
+ props: undefined,
306
+ cached: undefined,
307
+ shared: undefined,
308
+ priv: {
309
+ fields: symbolTable || new Map(),
310
+ docString: undefined,
311
+ notPresentFieldType: undefined,
312
+ loaderFields: new Map(),
313
+ moduleName,
314
+ fileUri,
315
+ },
247
316
  };
248
317
  return newModuleType;
249
318
  }
@@ -252,16 +321,16 @@ var ModuleType;
252
321
  // Always look for the symbol in the module's fields before consulting
253
322
  // the loader fields. The loader runs before the module, so its values
254
323
  // will be overwritten by the module.
255
- let symbol = moduleType.fields.get(name);
256
- if (moduleType.loaderFields) {
324
+ let symbol = moduleType.priv.fields.get(name);
325
+ if (moduleType.priv.loaderFields) {
257
326
  if (!symbol) {
258
- symbol = moduleType.loaderFields.get(name);
327
+ symbol = moduleType.priv.loaderFields.get(name);
259
328
  }
260
329
  else if (symbol.getDeclarations().length === 1) {
261
330
  // If the symbol is hidden when accessed via the module but is
262
331
  // also accessible through a loader field, use the latter so it
263
332
  // isn't flagged as an error.
264
- const loaderSymbol = moduleType.loaderFields.get(name);
333
+ const loaderSymbol = moduleType.priv.loaderFields.get(name);
265
334
  if (loaderSymbol && !loaderSymbol.isExternallyHidden()) {
266
335
  symbol = loaderSymbol;
267
336
  }
@@ -275,7 +344,7 @@ var ClassTypeFlags;
275
344
  (function (ClassTypeFlags) {
276
345
  ClassTypeFlags[ClassTypeFlags["None"] = 0] = "None";
277
346
  // Class is defined in the "builtins" or "typing" file.
278
- ClassTypeFlags[ClassTypeFlags["BuiltInClass"] = 1] = "BuiltInClass";
347
+ ClassTypeFlags[ClassTypeFlags["BuiltIn"] = 1] = "BuiltIn";
279
348
  // Class requires special-case handling because it
280
349
  // exhibits non-standard behavior or is not defined
281
350
  // formally as a class. Examples include 'Optional'
@@ -358,7 +427,10 @@ var ClassType;
358
427
  function createInstantiable(name, fullName, moduleName, fileUri, flags, typeSourceId, declaredMetaclass, effectiveMetaclass, docString) {
359
428
  const newClass = {
360
429
  category: 6 /* TypeCategory.Class */,
361
- details: {
430
+ flags: 1 /* TypeFlags.Instantiable */,
431
+ props: undefined,
432
+ cached: undefined,
433
+ shared: {
362
434
  name,
363
435
  fullName,
364
436
  moduleName,
@@ -373,13 +445,13 @@ var ClassType;
373
445
  typeParameters: [],
374
446
  docString,
375
447
  },
376
- flags: 1 /* TypeFlags.Instantiable */,
448
+ priv: {},
377
449
  };
378
450
  return newClass;
379
451
  }
380
452
  ClassType.createInstantiable = createInstantiable;
381
453
  function cloneAsInstance(type, includeSubclasses = true) {
382
- var _a;
454
+ var _a, _b;
383
455
  if (TypeBase.isInstance(type)) {
384
456
  return type;
385
457
  }
@@ -387,9 +459,11 @@ var ClassType;
387
459
  return type.cached.typeBaseInstanceType;
388
460
  }
389
461
  const newInstance = TypeBase.cloneTypeAsInstance(type, /* cache */ includeSubclasses);
390
- delete newInstance.specialForm;
462
+ if ((_b = newInstance.props) === null || _b === void 0 ? void 0 : _b.specialForm) {
463
+ TypeBase.setSpecialForm(newInstance, undefined);
464
+ }
391
465
  if (includeSubclasses) {
392
- newInstance.includeSubclasses = true;
466
+ newInstance.priv.includeSubclasses = true;
393
467
  }
394
468
  return newInstance;
395
469
  }
@@ -401,131 +475,136 @@ var ClassType;
401
475
  }
402
476
  const newInstance = TypeBase.cloneTypeAsInstantiable(type, includeSubclasses);
403
477
  if (includeSubclasses) {
404
- newInstance.includeSubclasses = true;
478
+ newInstance.priv.includeSubclasses = true;
405
479
  }
406
480
  return newInstance;
407
481
  }
408
482
  ClassType.cloneAsInstantiable = cloneAsInstantiable;
409
483
  function cloneForSpecialization(classType, typeArguments, isTypeArgumentExplicit, includeSubclasses = false, tupleTypeArguments, isEmptyContainer) {
410
484
  const newClassType = TypeBase.cloneType(classType);
411
- newClassType.typeArguments = (typeArguments === null || typeArguments === void 0 ? void 0 : typeArguments.length) === 0 ? undefined : typeArguments;
412
- newClassType.isTypeArgumentExplicit = isTypeArgumentExplicit;
485
+ newClassType.priv.typeArguments = (typeArguments === null || typeArguments === void 0 ? void 0 : typeArguments.length) === 0 ? undefined : typeArguments;
486
+ newClassType.priv.isTypeArgumentExplicit = isTypeArgumentExplicit;
413
487
  if (includeSubclasses) {
414
- newClassType.includeSubclasses = true;
488
+ newClassType.priv.includeSubclasses = true;
415
489
  }
416
- newClassType.tupleTypeArguments = tupleTypeArguments ? [...tupleTypeArguments] : undefined;
490
+ newClassType.priv.tupleTypeArguments = tupleTypeArguments ? [...tupleTypeArguments] : undefined;
417
491
  if (isEmptyContainer !== undefined) {
418
- newClassType.isEmptyContainer = isEmptyContainer;
492
+ newClassType.priv.isEmptyContainer = isEmptyContainer;
419
493
  }
420
494
  return newClassType;
421
495
  }
422
496
  ClassType.cloneForSpecialization = cloneForSpecialization;
423
497
  function cloneIncludeSubclasses(classType, includeSubclasses = true) {
424
- if (!!classType.includeSubclasses === includeSubclasses) {
498
+ if (!!classType.priv.includeSubclasses === includeSubclasses) {
425
499
  return classType;
426
500
  }
427
501
  const newClassType = TypeBase.cloneType(classType);
428
- newClassType.includeSubclasses = includeSubclasses;
502
+ newClassType.priv.includeSubclasses = includeSubclasses;
429
503
  return newClassType;
430
504
  }
431
505
  ClassType.cloneIncludeSubclasses = cloneIncludeSubclasses;
432
506
  function cloneWithLiteral(classType, value) {
507
+ var _a;
433
508
  const newClassType = TypeBase.cloneType(classType);
434
- newClassType.literalValue = value;
509
+ newClassType.priv.literalValue = value;
435
510
  // Remove type alias information because the type will no longer match
436
511
  // that of the type alias definition if we change the literal type.
437
- delete newClassType.typeAliasInfo;
512
+ if ((_a = newClassType.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo) {
513
+ TypeBase.setTypeAliasInfo(newClassType, undefined);
514
+ }
438
515
  return newClassType;
439
516
  }
440
517
  ClassType.cloneWithLiteral = cloneWithLiteral;
441
518
  function cloneForDeprecatedInstance(type, deprecatedMessage) {
442
519
  const newClassType = TypeBase.cloneType(type);
443
- newClassType.deprecatedInstanceMessage = deprecatedMessage;
520
+ newClassType.priv.deprecatedInstanceMessage = deprecatedMessage;
444
521
  return newClassType;
445
522
  }
446
523
  ClassType.cloneForDeprecatedInstance = cloneForDeprecatedInstance;
447
524
  function cloneForTypingAlias(classType, aliasName) {
448
525
  const newClassType = TypeBase.cloneType(classType);
449
- newClassType.aliasName = aliasName;
526
+ newClassType.priv.aliasName = aliasName;
450
527
  return newClassType;
451
528
  }
452
529
  ClassType.cloneForTypingAlias = cloneForTypingAlias;
453
530
  function cloneForNarrowedTypedDictEntries(classType, narrowedEntries) {
454
531
  const newClassType = TypeBase.cloneType(classType);
455
- newClassType.typedDictNarrowedEntries = narrowedEntries;
532
+ newClassType.priv.typedDictNarrowedEntries = narrowedEntries;
456
533
  return newClassType;
457
534
  }
458
535
  ClassType.cloneForNarrowedTypedDictEntries = cloneForNarrowedTypedDictEntries;
459
536
  function cloneForPartialTypedDict(classType) {
460
537
  const newClassType = TypeBase.cloneType(classType);
461
- newClassType.isTypedDictPartial = true;
538
+ newClassType.priv.isTypedDictPartial = true;
462
539
  return newClassType;
463
540
  }
464
541
  ClassType.cloneForPartialTypedDict = cloneForPartialTypedDict;
465
542
  function cloneRemoveTypePromotions(classType) {
466
- if (!classType.includePromotions) {
543
+ if (!classType.priv.includePromotions) {
467
544
  return classType;
468
545
  }
469
546
  const newClassType = TypeBase.cloneType(classType);
470
- delete newClassType.includePromotions;
547
+ if (newClassType.priv.includePromotions !== undefined) {
548
+ newClassType.priv.includePromotions = undefined;
549
+ }
471
550
  return newClassType;
472
551
  }
473
552
  ClassType.cloneRemoveTypePromotions = cloneRemoveTypePromotions;
474
553
  function cloneForTypeGuard(classType, typeGuardType, isStrictTypeGuard) {
475
554
  const newClassType = TypeBase.cloneType(classType);
476
- newClassType.typeGuardType = typeGuardType;
477
- newClassType.isStrictTypeGuard = isStrictTypeGuard;
555
+ newClassType.priv.typeGuardType = typeGuardType;
556
+ newClassType.priv.isStrictTypeGuard = isStrictTypeGuard;
478
557
  return newClassType;
479
558
  }
480
559
  ClassType.cloneForTypeGuard = cloneForTypeGuard;
481
560
  function cloneForSymbolTableUpdate(classType) {
482
561
  const newClassType = TypeBase.cloneType(classType);
483
- newClassType.details = { ...newClassType.details };
484
- newClassType.details.fields = new Map(newClassType.details.fields);
485
- newClassType.details.mro = Array.from(newClassType.details.mro);
486
- newClassType.details.mro[0] = cloneAsInstantiable(newClassType);
562
+ newClassType.shared = { ...newClassType.shared };
563
+ newClassType.shared.fields = new Map(newClassType.shared.fields);
564
+ newClassType.shared.mro = Array.from(newClassType.shared.mro);
565
+ newClassType.shared.mro[0] = cloneAsInstantiable(newClassType);
487
566
  return newClassType;
488
567
  }
489
568
  ClassType.cloneForSymbolTableUpdate = cloneForSymbolTableUpdate;
490
569
  function cloneForUnpacked(classType, isUnpacked = true) {
491
570
  const newClassType = TypeBase.cloneType(classType);
492
- newClassType.isUnpacked = isUnpacked;
571
+ newClassType.priv.isUnpacked = isUnpacked;
493
572
  return newClassType;
494
573
  }
495
574
  ClassType.cloneForUnpacked = cloneForUnpacked;
496
575
  function cloneWithNewFlags(classType, newFlags) {
497
576
  const newClassType = TypeBase.cloneType(classType);
498
- newClassType.details = { ...newClassType.details };
499
- newClassType.details.flags = newFlags;
577
+ newClassType.shared = { ...newClassType.shared };
578
+ newClassType.shared.flags = newFlags;
500
579
  return newClassType;
501
580
  }
502
581
  ClassType.cloneWithNewFlags = cloneWithNewFlags;
503
582
  function isLiteralValueSame(type1, type2) {
504
- if (type1.literalValue === undefined) {
505
- return type2.literalValue === undefined;
583
+ if (type1.priv.literalValue === undefined) {
584
+ return type2.priv.literalValue === undefined;
506
585
  }
507
- else if (type2.literalValue === undefined) {
586
+ else if (type2.priv.literalValue === undefined) {
508
587
  return false;
509
588
  }
510
- if (type1.literalValue instanceof EnumLiteral) {
511
- if (type2.literalValue instanceof EnumLiteral) {
512
- return type1.literalValue.itemName === type2.literalValue.itemName;
589
+ if (type1.priv.literalValue instanceof EnumLiteral) {
590
+ if (type2.priv.literalValue instanceof EnumLiteral) {
591
+ return type1.priv.literalValue.itemName === type2.priv.literalValue.itemName;
513
592
  }
514
593
  return false;
515
594
  }
516
- return type1.literalValue === type2.literalValue;
595
+ return type1.priv.literalValue === type2.priv.literalValue;
517
596
  }
518
597
  ClassType.isLiteralValueSame = isLiteralValueSame;
519
598
  // Determines whether two typed dict classes are equivalent given
520
599
  // that one or both have narrowed entries (i.e. entries that are
521
600
  // guaranteed to be present).
522
601
  function isTypedDictNarrowedEntriesSame(type1, type2) {
523
- if (type1.typedDictNarrowedEntries) {
524
- if (!type2.typedDictNarrowedEntries) {
602
+ if (type1.priv.typedDictNarrowedEntries) {
603
+ if (!type2.priv.typedDictNarrowedEntries) {
525
604
  return false;
526
605
  }
527
- const tdEntries1 = type1.typedDictNarrowedEntries;
528
- const tdEntries2 = type2.typedDictNarrowedEntries;
606
+ const tdEntries1 = type1.priv.typedDictNarrowedEntries;
607
+ const tdEntries2 = type2.priv.typedDictNarrowedEntries;
529
608
  if (tdEntries1.size !== tdEntries2.size) {
530
609
  return false;
531
610
  }
@@ -541,7 +620,7 @@ var ClassType;
541
620
  }
542
621
  }
543
622
  }
544
- else if (type2.typedDictNarrowedEntries) {
623
+ else if (type2.priv.typedDictNarrowedEntries) {
545
624
  return false;
546
625
  }
547
626
  return true;
@@ -552,11 +631,11 @@ var ClassType;
552
631
  // within type1.
553
632
  function isTypedDictNarrower(type1, type2) {
554
633
  var _a;
555
- const tdEntries2 = type2.typedDictNarrowedEntries;
634
+ const tdEntries2 = type2.priv.typedDictNarrowedEntries;
556
635
  if (!tdEntries2) {
557
636
  return true;
558
637
  }
559
- const tdEntries1 = (_a = type1.typedDictNarrowedEntries) !== null && _a !== void 0 ? _a : new Map();
638
+ const tdEntries1 = (_a = type1.priv.typedDictNarrowedEntries) !== null && _a !== void 0 ? _a : new Map();
560
639
  let key;
561
640
  let entry2;
562
641
  for ([key, entry2] of tdEntries2.entries()) {
@@ -572,189 +651,189 @@ var ClassType;
572
651
  ClassType.isTypedDictNarrower = isTypedDictNarrower;
573
652
  // Is the class generic but not specialized?
574
653
  function isUnspecialized(classType) {
575
- return classType.details.typeParameters.length > 0 && classType.typeArguments === undefined;
654
+ return classType.shared.typeParameters.length > 0 && classType.priv.typeArguments === undefined;
576
655
  }
577
656
  ClassType.isUnspecialized = isUnspecialized;
578
657
  function isSpecialBuiltIn(classType, className) {
579
- if (!(classType.details.flags & 2 /* ClassTypeFlags.SpecialBuiltIn */) && !classType.aliasName) {
658
+ if (!(classType.shared.flags & 2 /* ClassTypeFlags.SpecialBuiltIn */) && !classType.priv.aliasName) {
580
659
  return false;
581
660
  }
582
661
  if (className !== undefined) {
583
- return classType.details.name === className;
662
+ return classType.shared.name === className;
584
663
  }
585
664
  return true;
586
665
  }
587
666
  ClassType.isSpecialBuiltIn = isSpecialBuiltIn;
588
667
  function isBuiltIn(classType, className) {
589
- if (!(classType.details.flags & 1 /* ClassTypeFlags.BuiltInClass */)) {
668
+ if (!(classType.shared.flags & 1 /* ClassTypeFlags.BuiltIn */)) {
590
669
  return false;
591
670
  }
592
671
  if (className !== undefined) {
593
672
  const classArray = Array.isArray(className) ? className : [className];
594
- return (classArray.some((name) => name === classType.details.name) ||
595
- classArray.some((name) => name === classType.aliasName));
673
+ return (classArray.some((name) => name === classType.shared.name) ||
674
+ classArray.some((name) => name === classType.priv.aliasName));
596
675
  }
597
676
  return true;
598
677
  }
599
678
  ClassType.isBuiltIn = isBuiltIn;
600
679
  function supportsAbstractMethods(classType) {
601
- return !!(classType.details.flags & 64 /* ClassTypeFlags.SupportsAbstractMethods */);
680
+ return !!(classType.shared.flags & 64 /* ClassTypeFlags.SupportsAbstractMethods */);
602
681
  }
603
682
  ClassType.supportsAbstractMethods = supportsAbstractMethods;
604
683
  function isDataClass(classType) {
605
- return !!classType.details.dataClassBehaviors;
684
+ return !!classType.shared.dataClassBehaviors;
606
685
  }
607
686
  ClassType.isDataClass = isDataClass;
608
687
  function isDataClassSkipGenerateInit(classType) {
609
688
  var _a;
610
- return !!((_a = classType.details.dataClassBehaviors) === null || _a === void 0 ? void 0 : _a.skipGenerateInit);
689
+ return !!((_a = classType.shared.dataClassBehaviors) === null || _a === void 0 ? void 0 : _a.skipGenerateInit);
611
690
  }
612
691
  ClassType.isDataClassSkipGenerateInit = isDataClassSkipGenerateInit;
613
692
  function isDataClassSkipGenerateEq(classType) {
614
693
  var _a;
615
- return !!((_a = classType.details.dataClassBehaviors) === null || _a === void 0 ? void 0 : _a.skipGenerateEq);
694
+ return !!((_a = classType.shared.dataClassBehaviors) === null || _a === void 0 ? void 0 : _a.skipGenerateEq);
616
695
  }
617
696
  ClassType.isDataClassSkipGenerateEq = isDataClassSkipGenerateEq;
618
697
  function isDataClassFrozen(classType) {
619
698
  var _a;
620
- return !!((_a = classType.details.dataClassBehaviors) === null || _a === void 0 ? void 0 : _a.frozen);
699
+ return !!((_a = classType.shared.dataClassBehaviors) === null || _a === void 0 ? void 0 : _a.frozen);
621
700
  }
622
701
  ClassType.isDataClassFrozen = isDataClassFrozen;
623
702
  function isDataClassGenerateOrder(classType) {
624
703
  var _a;
625
- return !!((_a = classType.details.dataClassBehaviors) === null || _a === void 0 ? void 0 : _a.generateOrder);
704
+ return !!((_a = classType.shared.dataClassBehaviors) === null || _a === void 0 ? void 0 : _a.generateOrder);
626
705
  }
627
706
  ClassType.isDataClassGenerateOrder = isDataClassGenerateOrder;
628
707
  function isDataClassKeywordOnly(classType) {
629
708
  var _a;
630
- return !!((_a = classType.details.dataClassBehaviors) === null || _a === void 0 ? void 0 : _a.keywordOnly);
709
+ return !!((_a = classType.shared.dataClassBehaviors) === null || _a === void 0 ? void 0 : _a.keywordOnly);
631
710
  }
632
711
  ClassType.isDataClassKeywordOnly = isDataClassKeywordOnly;
633
712
  function isDataClassGenerateSlots(classType) {
634
713
  var _a;
635
- return !!((_a = classType.details.dataClassBehaviors) === null || _a === void 0 ? void 0 : _a.generateSlots);
714
+ return !!((_a = classType.shared.dataClassBehaviors) === null || _a === void 0 ? void 0 : _a.generateSlots);
636
715
  }
637
716
  ClassType.isDataClassGenerateSlots = isDataClassGenerateSlots;
638
717
  function isDataClassGenerateHash(classType) {
639
718
  var _a;
640
- return !!((_a = classType.details.dataClassBehaviors) === null || _a === void 0 ? void 0 : _a.generateHash);
719
+ return !!((_a = classType.shared.dataClassBehaviors) === null || _a === void 0 ? void 0 : _a.generateHash);
641
720
  }
642
721
  ClassType.isDataClassGenerateHash = isDataClassGenerateHash;
643
722
  function isTypeCheckOnly(classType) {
644
- return !!(classType.details.flags & 1048576 /* ClassTypeFlags.TypeCheckOnly */);
723
+ return !!(classType.shared.flags & 1048576 /* ClassTypeFlags.TypeCheckOnly */);
645
724
  }
646
725
  ClassType.isTypeCheckOnly = isTypeCheckOnly;
647
726
  function isNewTypeClass(classType) {
648
- return !!(classType.details.flags & 2097152 /* ClassTypeFlags.NewTypeClass */);
727
+ return !!(classType.shared.flags & 2097152 /* ClassTypeFlags.NewTypeClass */);
649
728
  }
650
729
  ClassType.isNewTypeClass = isNewTypeClass;
651
730
  function isValidTypeAliasClass(classType) {
652
- return !!(classType.details.flags & 4194304 /* ClassTypeFlags.ValidTypeAliasClass */);
731
+ return !!(classType.shared.flags & 4194304 /* ClassTypeFlags.ValidTypeAliasClass */);
653
732
  }
654
733
  ClassType.isValidTypeAliasClass = isValidTypeAliasClass;
655
734
  function isSpecialFormClass(classType) {
656
- return !!(classType.details.flags & 8388608 /* ClassTypeFlags.SpecialFormClass */);
735
+ return !!(classType.shared.flags & 8388608 /* ClassTypeFlags.SpecialFormClass */);
657
736
  }
658
737
  ClassType.isSpecialFormClass = isSpecialFormClass;
659
738
  function isIllegalIsinstanceClass(classType) {
660
- return !!(classType.details.flags & 16777216 /* ClassTypeFlags.IllegalIsinstanceClass */);
739
+ return !!(classType.shared.flags & 16777216 /* ClassTypeFlags.IllegalIsinstanceClass */);
661
740
  }
662
741
  ClassType.isIllegalIsinstanceClass = isIllegalIsinstanceClass;
663
742
  function isTypedDictClass(classType) {
664
- return !!(classType.details.flags & 4 /* ClassTypeFlags.TypedDictClass */);
743
+ return !!(classType.shared.flags & 4 /* ClassTypeFlags.TypedDictClass */);
665
744
  }
666
745
  ClassType.isTypedDictClass = isTypedDictClass;
667
746
  function isCanOmitDictValues(classType) {
668
- return !!(classType.details.flags & 32 /* ClassTypeFlags.CanOmitDictValues */);
747
+ return !!(classType.shared.flags & 32 /* ClassTypeFlags.CanOmitDictValues */);
669
748
  }
670
749
  ClassType.isCanOmitDictValues = isCanOmitDictValues;
671
750
  function isTypedDictMarkedClosed(classType) {
672
- return !!(classType.details.flags & 8 /* ClassTypeFlags.TypedDictMarkedClosed */);
751
+ return !!(classType.shared.flags & 8 /* ClassTypeFlags.TypedDictMarkedClosed */);
673
752
  }
674
753
  ClassType.isTypedDictMarkedClosed = isTypedDictMarkedClosed;
675
754
  function isTypedDictEffectivelyClosed(classType) {
676
- return !!(classType.details.flags & 16 /* ClassTypeFlags.TypedDictEffectivelyClosed */);
755
+ return !!(classType.shared.flags & 16 /* ClassTypeFlags.TypedDictEffectivelyClosed */);
677
756
  }
678
757
  ClassType.isTypedDictEffectivelyClosed = isTypedDictEffectivelyClosed;
679
758
  function isEnumClass(classType) {
680
- return !!(classType.details.flags & 65536 /* ClassTypeFlags.EnumClass */);
759
+ return !!(classType.shared.flags & 65536 /* ClassTypeFlags.EnumClass */);
681
760
  }
682
761
  ClassType.isEnumClass = isEnumClass;
683
762
  function isPropertyClass(classType) {
684
- return !!(classType.details.flags & 128 /* ClassTypeFlags.PropertyClass */);
763
+ return !!(classType.shared.flags & 128 /* ClassTypeFlags.PropertyClass */);
685
764
  }
686
765
  ClassType.isPropertyClass = isPropertyClass;
687
766
  function isClassProperty(classType) {
688
- return !!(classType.details.flags & 131072 /* ClassTypeFlags.ClassProperty */);
767
+ return !!(classType.shared.flags & 131072 /* ClassTypeFlags.ClassProperty */);
689
768
  }
690
769
  ClassType.isClassProperty = isClassProperty;
691
770
  function isFinal(classType) {
692
- return !!(classType.details.flags & 256 /* ClassTypeFlags.Final */);
771
+ return !!(classType.shared.flags & 256 /* ClassTypeFlags.Final */);
693
772
  }
694
773
  ClassType.isFinal = isFinal;
695
774
  function isProtocolClass(classType) {
696
- return !!(classType.details.flags & 512 /* ClassTypeFlags.ProtocolClass */);
775
+ return !!(classType.shared.flags & 512 /* ClassTypeFlags.ProtocolClass */);
697
776
  }
698
777
  ClassType.isProtocolClass = isProtocolClass;
699
778
  function isDefinedInStub(classType) {
700
- return !!(classType.details.flags & 262144 /* ClassTypeFlags.DefinedInStub */);
779
+ return !!(classType.shared.flags & 262144 /* ClassTypeFlags.DefinedInStub */);
701
780
  }
702
781
  ClassType.isDefinedInStub = isDefinedInStub;
703
782
  function isPseudoGenericClass(classType) {
704
- return !!(classType.details.flags & 1024 /* ClassTypeFlags.PseudoGenericClass */);
783
+ return !!(classType.shared.flags & 1024 /* ClassTypeFlags.PseudoGenericClass */);
705
784
  }
706
785
  ClassType.isPseudoGenericClass = isPseudoGenericClass;
707
786
  function getDataClassEntries(classType) {
708
787
  var _a, _b;
709
- (_b = (_a = classType.details).synthesizeMethodsDeferred) === null || _b === void 0 ? void 0 : _b.call(_a);
710
- return classType.details.dataClassEntries || [];
788
+ (_b = (_a = classType.shared).synthesizeMethodsDeferred) === null || _b === void 0 ? void 0 : _b.call(_a);
789
+ return classType.shared.dataClassEntries || [];
711
790
  }
712
791
  ClassType.getDataClassEntries = getDataClassEntries;
713
792
  function isRuntimeCheckable(classType) {
714
- return !!(classType.details.flags & 2048 /* ClassTypeFlags.RuntimeCheckable */);
793
+ return !!(classType.shared.flags & 2048 /* ClassTypeFlags.RuntimeCheckable */);
715
794
  }
716
795
  ClassType.isRuntimeCheckable = isRuntimeCheckable;
717
796
  function isTypingExtensionClass(classType) {
718
- return !!(classType.details.flags & 4096 /* ClassTypeFlags.TypingExtensionClass */);
797
+ return !!(classType.shared.flags & 4096 /* ClassTypeFlags.TypingExtensionClass */);
719
798
  }
720
799
  ClassType.isTypingExtensionClass = isTypingExtensionClass;
721
800
  function isPartiallyEvaluated(classType) {
722
- return !!(classType.details.flags & 8192 /* ClassTypeFlags.PartiallyEvaluated */);
801
+ return !!(classType.shared.flags & 8192 /* ClassTypeFlags.PartiallyEvaluated */);
723
802
  }
724
803
  ClassType.isPartiallyEvaluated = isPartiallyEvaluated;
725
804
  function hasCustomClassGetItem(classType) {
726
- return !!(classType.details.flags & 16384 /* ClassTypeFlags.HasCustomClassGetItem */);
805
+ return !!(classType.shared.flags & 16384 /* ClassTypeFlags.HasCustomClassGetItem */);
727
806
  }
728
807
  ClassType.hasCustomClassGetItem = hasCustomClassGetItem;
729
808
  function isTupleClass(classType) {
730
- return !!(classType.details.flags & 32768 /* ClassTypeFlags.TupleClass */);
809
+ return !!(classType.shared.flags & 32768 /* ClassTypeFlags.TupleClass */);
731
810
  }
732
811
  ClassType.isTupleClass = isTupleClass;
733
812
  function isReadOnlyInstanceVariables(classType) {
734
- return !!(classType.details.flags & 524288 /* ClassTypeFlags.ReadOnlyInstanceVariables */);
813
+ return !!(classType.shared.flags & 524288 /* ClassTypeFlags.ReadOnlyInstanceVariables */);
735
814
  }
736
815
  ClassType.isReadOnlyInstanceVariables = isReadOnlyInstanceVariables;
737
816
  function getTypeParameters(classType) {
738
- return classType.details.typeParameters;
817
+ return classType.shared.typeParameters;
739
818
  }
740
819
  ClassType.getTypeParameters = getTypeParameters;
741
820
  function derivesFromAnyOrUnknown(classType) {
742
- return classType.details.mro.some((baseClass) => isAnyOrUnknown(baseClass));
821
+ return classType.shared.mro.some((baseClass) => isAnyOrUnknown(baseClass));
743
822
  }
744
823
  ClassType.derivesFromAnyOrUnknown = derivesFromAnyOrUnknown;
745
824
  function getSymbolTable(classType) {
746
825
  var _a, _b;
747
- (_b = (_a = classType.details).synthesizeMethodsDeferred) === null || _b === void 0 ? void 0 : _b.call(_a);
748
- return classType.details.fields;
826
+ (_b = (_a = classType.shared).synthesizeMethodsDeferred) === null || _b === void 0 ? void 0 : _b.call(_a);
827
+ return classType.shared.fields;
749
828
  }
750
829
  ClassType.getSymbolTable = getSymbolTable;
751
830
  function getInheritedSlotsNames(classType) {
752
831
  var _a, _b, _c, _d;
753
832
  // First synthesize methods if needed. The slots entries
754
833
  // can depend on synthesized methods.
755
- (_b = (_a = classType.details).synthesizeMethodsDeferred) === null || _b === void 0 ? void 0 : _b.call(_a);
756
- (_d = (_c = classType.details).calculateInheritedSlotsNamesDeferred) === null || _d === void 0 ? void 0 : _d.call(_c);
757
- return classType.details.inheritedSlotsNamesCached;
834
+ (_b = (_a = classType.shared).synthesizeMethodsDeferred) === null || _b === void 0 ? void 0 : _b.call(_a);
835
+ (_d = (_c = classType.shared).calculateInheritedSlotsNamesDeferred) === null || _d === void 0 ? void 0 : _d.call(_c);
836
+ return classType.shared.inheritedSlotsNamesCached;
758
837
  }
759
838
  ClassType.getInheritedSlotsNames = getInheritedSlotsNames;
760
839
  // Similar to isPartiallyEvaluated except that it also looks at all of the
@@ -762,16 +841,16 @@ var ClassType;
762
841
  // partially evaluated.
763
842
  function isHierarchyPartiallyEvaluated(classType) {
764
843
  return (ClassType.isPartiallyEvaluated(classType) ||
765
- classType.details.mro.some((mroClass) => isClass(mroClass) && ClassType.isPartiallyEvaluated(mroClass)));
844
+ classType.shared.mro.some((mroClass) => isClass(mroClass) && ClassType.isPartiallyEvaluated(mroClass)));
766
845
  }
767
846
  ClassType.isHierarchyPartiallyEvaluated = isHierarchyPartiallyEvaluated;
768
847
  // Same as isTypeSame except that it doesn't compare type arguments.
769
848
  function isSameGenericClass(classType, type2, recursionCount = 0) {
770
- if (!classType.isTypedDictPartial !== !type2.isTypedDictPartial) {
849
+ if (!classType.priv.isTypedDictPartial !== !type2.priv.isTypedDictPartial) {
771
850
  return false;
772
851
  }
773
- const class1Details = classType.details;
774
- const class2Details = type2.details;
852
+ const class1Details = classType.shared;
853
+ const class2Details = type2.shared;
775
854
  if (class1Details === class2Details) {
776
855
  return true;
777
856
  }
@@ -826,8 +905,8 @@ var ClassType;
826
905
  // Is it the exact same class?
827
906
  if (isSameGenericClass(subclassType, parentClassType)) {
828
907
  // Handle literal types.
829
- if (parentClassType.literalValue !== undefined) {
830
- if (subclassType.literalValue === undefined ||
908
+ if (parentClassType.priv.literalValue !== undefined) {
909
+ if (subclassType.priv.literalValue === undefined ||
831
910
  !ClassType.isLiteralValueSame(parentClassType, subclassType)) {
832
911
  return false;
833
912
  }
@@ -855,7 +934,7 @@ var ClassType;
855
934
  }
856
935
  return true;
857
936
  }
858
- for (const baseClass of subclassType.details.baseClasses) {
937
+ for (const baseClass of subclassType.shared.baseClasses) {
859
938
  if (isInstantiableClass(baseClass)) {
860
939
  if (isDerivedFrom(baseClass, parentClassType, inheritanceChain)) {
861
940
  if (inheritanceChain) {
@@ -875,10 +954,39 @@ var ClassType;
875
954
  }
876
955
  ClassType.isDerivedFrom = isDerivedFrom;
877
956
  function getReverseMro(classType) {
878
- return classType.details.mro.slice(0).reverse();
957
+ return classType.shared.mro.slice(0).reverse();
879
958
  }
880
959
  ClassType.getReverseMro = getReverseMro;
881
960
  })(ClassType || (exports.ClassType = ClassType = {}));
961
+ var FunctionParamFlags;
962
+ (function (FunctionParamFlags) {
963
+ FunctionParamFlags[FunctionParamFlags["None"] = 0] = "None";
964
+ // Is the name of the parameter synthesize internally?
965
+ FunctionParamFlags[FunctionParamFlags["NameSynthesized"] = 1] = "NameSynthesized";
966
+ // Does the parameter have an explicitly-declared type?
967
+ FunctionParamFlags[FunctionParamFlags["TypeDeclared"] = 2] = "TypeDeclared";
968
+ // Is the type of the parameter inferred?
969
+ FunctionParamFlags[FunctionParamFlags["TypeInferred"] = 4] = "TypeInferred";
970
+ })(FunctionParamFlags || (exports.FunctionParamFlags = FunctionParamFlags = {}));
971
+ var FunctionParam;
972
+ (function (FunctionParam) {
973
+ function create(category, type, flags = FunctionParamFlags.None, name, defaultType) {
974
+ return { category, type, flags, name, defaultType };
975
+ }
976
+ FunctionParam.create = create;
977
+ function isNameSynthesized(param) {
978
+ return !!(param.flags & FunctionParamFlags.NameSynthesized);
979
+ }
980
+ FunctionParam.isNameSynthesized = isNameSynthesized;
981
+ function isTypeDeclared(param) {
982
+ return !!(param.flags & FunctionParamFlags.TypeDeclared);
983
+ }
984
+ FunctionParam.isTypeDeclared = isTypeDeclared;
985
+ function isTypeInferred(param) {
986
+ return !!(param.flags & FunctionParamFlags.TypeInferred);
987
+ }
988
+ FunctionParam.isTypeInferred = isTypeInferred;
989
+ })(FunctionParam || (exports.FunctionParam = FunctionParam = {}));
882
990
  function isPositionOnlySeparator(param) {
883
991
  // A simple parameter with no name is treated as a "/" separator.
884
992
  return param.category === 0 /* ParameterCategory.Simple */ && !param.name;
@@ -942,6 +1050,8 @@ var FunctionTypeFlags;
942
1050
  FunctionTypeFlags[FunctionTypeFlags["Overridden"] = 262144] = "Overridden";
943
1051
  // Decorated with @no_type_check.
944
1052
  FunctionTypeFlags[FunctionTypeFlags["NoTypeCheck"] = 524288] = "NoTypeCheck";
1053
+ // Function defined in one of the core stdlib modules.
1054
+ FunctionTypeFlags[FunctionTypeFlags["BuiltIn"] = 1048576] = "BuiltIn";
945
1055
  })(FunctionTypeFlags || (exports.FunctionTypeFlags = FunctionTypeFlags = {}));
946
1056
  var FunctionType;
947
1057
  (function (FunctionType) {
@@ -960,37 +1070,48 @@ var FunctionType;
960
1070
  function create(name, fullName, moduleName, functionFlags, typeFlags, docString) {
961
1071
  const newFunctionType = {
962
1072
  category: 4 /* TypeCategory.Function */,
963
- details: {
1073
+ flags: typeFlags,
1074
+ props: undefined,
1075
+ cached: undefined,
1076
+ shared: {
964
1077
  name,
965
1078
  fullName,
966
1079
  moduleName,
967
1080
  flags: functionFlags,
968
- parameters: [],
969
1081
  typeParameters: [],
1082
+ parameters: [],
1083
+ declaredReturnType: undefined,
1084
+ declaration: undefined,
1085
+ typeVarScopeId: undefined,
970
1086
  docString,
1087
+ deprecatedMessage: undefined,
1088
+ methodClass: undefined,
1089
+ decoratorDataClassBehaviors: undefined,
971
1090
  },
972
- flags: typeFlags,
1091
+ priv: {},
973
1092
  };
974
1093
  return newFunctionType;
975
1094
  }
976
1095
  // Creates a deep copy of the function type, including a fresh
977
1096
  // version of _functionDetails.
978
1097
  function clone(type, stripFirstParam = false, boundToType, boundTypeVarScopeId) {
979
- var _a;
1098
+ var _a, _b;
980
1099
  const newFunction = TypeBase.cloneType(type);
981
- newFunction.details = { ...type.details };
982
- newFunction.preBoundFlags = newFunction.details.flags;
983
- newFunction.boundToType = boundToType;
984
- newFunction.boundTypeVarScopeId = boundTypeVarScopeId;
1100
+ newFunction.shared = { ...type.shared };
1101
+ newFunction.priv.preBoundFlags = newFunction.shared.flags;
1102
+ newFunction.priv.boundToType = boundToType;
1103
+ if (boundTypeVarScopeId) {
1104
+ newFunction.priv.constructorTypeVarScopeId = boundTypeVarScopeId;
1105
+ }
985
1106
  if (stripFirstParam) {
986
- if (type.details.parameters.length > 0) {
987
- if (type.details.parameters[0].category === 0 /* ParameterCategory.Simple */) {
988
- if (type.details.parameters.length > 0 && !type.details.parameters[0].isTypeInferred) {
1107
+ if (type.shared.parameters.length > 0) {
1108
+ if (type.shared.parameters[0].category === 0 /* ParameterCategory.Simple */) {
1109
+ if (type.shared.parameters.length > 0 && !FunctionParam.isTypeInferred(type.shared.parameters[0])) {
989
1110
  // Stash away the effective type of the first parameter if it
990
1111
  // wasn't synthesized.
991
- newFunction.strippedFirstParamType = getEffectiveParameterType(type, 0);
1112
+ newFunction.priv.strippedFirstParamType = getEffectiveParameterType(type, 0);
992
1113
  }
993
- newFunction.details.parameters = type.details.parameters.slice(1);
1114
+ newFunction.shared.parameters = type.shared.parameters.slice(1);
994
1115
  }
995
1116
  }
996
1117
  else {
@@ -998,34 +1119,36 @@ var FunctionType;
998
1119
  }
999
1120
  // If we strip off the first parameter, this is no longer an
1000
1121
  // instance method or class method.
1001
- newFunction.details.flags &= ~(1 /* FunctionTypeFlags.ConstructorMethod */ | 2 /* FunctionTypeFlags.ClassMethod */);
1002
- newFunction.details.flags |= 4 /* FunctionTypeFlags.StaticMethod */;
1122
+ newFunction.shared.flags &= ~(1 /* FunctionTypeFlags.ConstructorMethod */ | 2 /* FunctionTypeFlags.ClassMethod */);
1123
+ newFunction.shared.flags |= 4 /* FunctionTypeFlags.StaticMethod */;
1003
1124
  }
1004
- if (type.typeAliasInfo !== undefined) {
1005
- newFunction.typeAliasInfo = type.typeAliasInfo;
1125
+ if ((_a = type.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo) {
1126
+ TypeBase.setTypeAliasInfo(newFunction, type.props.typeAliasInfo);
1006
1127
  }
1007
- if (type.specializedTypes) {
1008
- newFunction.specializedTypes = {
1128
+ if (type.priv.specializedTypes) {
1129
+ newFunction.priv.specializedTypes = {
1009
1130
  parameterTypes: stripFirstParam
1010
- ? type.specializedTypes.parameterTypes.slice(1)
1011
- : type.specializedTypes.parameterTypes,
1131
+ ? type.priv.specializedTypes.parameterTypes.slice(1)
1132
+ : type.priv.specializedTypes.parameterTypes,
1012
1133
  parameterDefaultArgs: stripFirstParam
1013
- ? (_a = type.specializedTypes.parameterDefaultArgs) === null || _a === void 0 ? void 0 : _a.slice(1)
1014
- : type.specializedTypes.parameterDefaultArgs,
1015
- returnType: type.specializedTypes.returnType,
1134
+ ? (_b = type.priv.specializedTypes.parameterDefaultArgs) === null || _b === void 0 ? void 0 : _b.slice(1)
1135
+ : type.priv.specializedTypes.parameterDefaultArgs,
1136
+ returnType: type.priv.specializedTypes.returnType,
1016
1137
  };
1017
1138
  }
1018
- newFunction.inferredReturnType = type.inferredReturnType;
1139
+ newFunction.priv.inferredReturnType = type.priv.inferredReturnType;
1019
1140
  return newFunction;
1020
1141
  }
1021
1142
  FunctionType.clone = clone;
1022
1143
  function cloneAsInstance(type) {
1023
- var _a;
1144
+ var _a, _b;
1024
1145
  if ((_a = type.cached) === null || _a === void 0 ? void 0 : _a.typeBaseInstanceType) {
1025
1146
  return type.cached.typeBaseInstanceType;
1026
1147
  }
1027
1148
  const newInstance = TypeBase.cloneTypeAsInstance(type, /* cache */ true);
1028
- delete newInstance.specialForm;
1149
+ if ((_b = newInstance.props) === null || _b === void 0 ? void 0 : _b.specialForm) {
1150
+ TypeBase.setSpecialForm(newInstance, undefined);
1151
+ }
1029
1152
  return newInstance;
1030
1153
  }
1031
1154
  FunctionType.cloneAsInstance = cloneAsInstance;
@@ -1043,65 +1166,59 @@ var FunctionType;
1043
1166
  // with the object being cloned.
1044
1167
  function cloneForSpecialization(type, specializedTypes, specializedInferredReturnType) {
1045
1168
  const newFunction = TypeBase.cloneType(type);
1046
- (0, debug_1.assert)(specializedTypes.parameterTypes.length === type.details.parameters.length);
1169
+ (0, debug_1.assert)(specializedTypes.parameterTypes.length === type.shared.parameters.length);
1047
1170
  if (specializedTypes.parameterDefaultArgs) {
1048
- (0, debug_1.assert)(specializedTypes.parameterDefaultArgs.length === type.details.parameters.length);
1171
+ (0, debug_1.assert)(specializedTypes.parameterDefaultArgs.length === type.shared.parameters.length);
1049
1172
  }
1050
- newFunction.specializedTypes = specializedTypes;
1051
- newFunction.inferredReturnType = specializedInferredReturnType;
1173
+ newFunction.priv.specializedTypes = specializedTypes;
1174
+ newFunction.priv.inferredReturnType = specializedInferredReturnType;
1052
1175
  return newFunction;
1053
1176
  }
1054
1177
  FunctionType.cloneForSpecialization = cloneForSpecialization;
1055
1178
  // Creates a new function based on the parameters of another function.
1056
1179
  function applyParamSpecValue(type, paramSpecValue) {
1057
- const hasPositionalOnly = paramSpecValue.details.parameters.some((param) => isPositionOnlySeparator(param));
1180
+ const hasPositionalOnly = paramSpecValue.shared.parameters.some((param) => isPositionOnlySeparator(param));
1058
1181
  const newFunction = FunctionType.cloneRemoveParamSpecArgsKwargs(TypeBase.cloneType(type), hasPositionalOnly);
1059
1182
  const paramSpec = FunctionType.getParamSpecFromArgsKwargs(type);
1060
1183
  (0, debug_1.assert)(paramSpec !== undefined);
1061
1184
  // Make a shallow clone of the details.
1062
- newFunction.details = { ...newFunction.details };
1063
- newFunction.details.typeParameters = newFunction.details.typeParameters.filter((t) => !isTypeSame(t, paramSpec));
1064
- const prevParams = Array.from(newFunction.details.parameters);
1065
- newFunction.details.parameters = [
1185
+ newFunction.shared = { ...newFunction.shared };
1186
+ newFunction.shared.typeParameters = newFunction.shared.typeParameters.filter((t) => !isTypeSame(t, paramSpec));
1187
+ const prevParams = Array.from(newFunction.shared.parameters);
1188
+ newFunction.shared.parameters = [
1066
1189
  ...prevParams,
1067
- ...paramSpecValue.details.parameters.map((param) => {
1068
- return {
1069
- category: param.category,
1070
- name: param.name,
1071
- hasDefault: param.hasDefault,
1072
- defaultValueExpression: param.defaultValueExpression,
1073
- isNameSynthesized: param.isNameSynthesized,
1074
- hasDeclaredType: true,
1075
- type: param.type,
1076
- };
1190
+ ...paramSpecValue.shared.parameters.map((param) => {
1191
+ return FunctionParam.create(param.category, param.type, (param.flags & FunctionParamFlags.NameSynthesized) | FunctionParamFlags.TypeDeclared, param.name, param.defaultType);
1077
1192
  }),
1078
1193
  ];
1079
- if (newFunction.details.docString === undefined) {
1080
- newFunction.details.docString = paramSpecValue.details.docString;
1194
+ if (newFunction.shared.docString === undefined) {
1195
+ newFunction.shared.docString = paramSpecValue.shared.docString;
1081
1196
  }
1082
- if (newFunction.details.deprecatedMessage === undefined) {
1083
- newFunction.details.deprecatedMessage = paramSpecValue.details.deprecatedMessage;
1197
+ if (newFunction.shared.deprecatedMessage === undefined) {
1198
+ newFunction.shared.deprecatedMessage = paramSpecValue.shared.deprecatedMessage;
1084
1199
  }
1085
1200
  const origFlagsMask = 256 /* FunctionTypeFlags.Overloaded */ | 65536 /* FunctionTypeFlags.ParamSpecValue */;
1086
- newFunction.details.flags = type.details.flags & origFlagsMask;
1201
+ newFunction.shared.flags = type.shared.flags & origFlagsMask;
1087
1202
  const methodFlagsMask = 2 /* FunctionTypeFlags.ClassMethod */ | 4 /* FunctionTypeFlags.StaticMethod */ | 1 /* FunctionTypeFlags.ConstructorMethod */;
1088
1203
  // If the original function was a method, use its method type. Otherwise
1089
1204
  // use the method type of the param spec.
1090
- if (type.details.methodClass) {
1091
- newFunction.details.flags |= type.details.flags & methodFlagsMask;
1205
+ if (type.shared.methodClass) {
1206
+ newFunction.shared.flags |= type.shared.flags & methodFlagsMask;
1092
1207
  }
1093
1208
  else {
1094
- newFunction.details.flags |= paramSpecValue.details.flags & methodFlagsMask;
1209
+ newFunction.shared.flags |= paramSpecValue.shared.flags & methodFlagsMask;
1095
1210
  }
1096
1211
  // Use the "..." flag from the param spec.
1097
- newFunction.details.flags |= paramSpecValue.details.flags & 32768 /* FunctionTypeFlags.GradualCallableForm */;
1212
+ newFunction.shared.flags |= paramSpecValue.shared.flags & 32768 /* FunctionTypeFlags.GradualCallableForm */;
1098
1213
  // Mark the function as synthesized since there is no user-defined declaration for it.
1099
- newFunction.details.flags |= 64 /* FunctionTypeFlags.SynthesizedMethod */;
1100
- delete newFunction.details.declaration;
1214
+ newFunction.shared.flags |= 64 /* FunctionTypeFlags.SynthesizedMethod */;
1215
+ if (newFunction.shared.declaration) {
1216
+ newFunction.shared.declaration = undefined;
1217
+ }
1101
1218
  // Update the specialized parameter types as well.
1102
- const specializedTypes = newFunction.specializedTypes;
1219
+ const specializedTypes = newFunction.priv.specializedTypes;
1103
1220
  if (specializedTypes) {
1104
- paramSpecValue.details.parameters.forEach((paramInfo) => {
1221
+ paramSpecValue.shared.parameters.forEach((paramInfo) => {
1105
1222
  var _a;
1106
1223
  specializedTypes.parameterTypes.push(paramInfo.type);
1107
1224
  // Assume that the parameters introduced via paramSpec have no specialized
@@ -1109,11 +1226,11 @@ var FunctionType;
1109
1226
  (_a = specializedTypes.parameterDefaultArgs) === null || _a === void 0 ? void 0 : _a.push(undefined);
1110
1227
  });
1111
1228
  }
1112
- FunctionType.addHigherOrderTypeVarScopeIds(newFunction, paramSpecValue.details.typeVarScopeId);
1113
- FunctionType.addHigherOrderTypeVarScopeIds(newFunction, paramSpecValue.details.higherOrderTypeVarScopeIds);
1114
- newFunction.details.constructorTypeVarScopeId = paramSpecValue.details.constructorTypeVarScopeId;
1115
- if (!newFunction.details.methodClass && paramSpecValue.details.methodClass) {
1116
- newFunction.details.methodClass = paramSpecValue.details.methodClass;
1229
+ FunctionType.addHigherOrderTypeVarScopeIds(newFunction, paramSpecValue.shared.typeVarScopeId);
1230
+ FunctionType.addHigherOrderTypeVarScopeIds(newFunction, paramSpecValue.priv.higherOrderTypeVarScopeIds);
1231
+ newFunction.priv.constructorTypeVarScopeId = paramSpecValue.priv.constructorTypeVarScopeId;
1232
+ if (!newFunction.shared.methodClass && paramSpecValue.shared.methodClass) {
1233
+ newFunction.shared.methodClass = paramSpecValue.shared.methodClass;
1117
1234
  }
1118
1235
  return newFunction;
1119
1236
  }
@@ -1121,35 +1238,35 @@ var FunctionType;
1121
1238
  function cloneWithNewFlags(type, flags) {
1122
1239
  const newFunction = TypeBase.cloneType(type);
1123
1240
  // Make a shallow clone of the details.
1124
- newFunction.details = { ...type.details };
1125
- newFunction.details.flags = flags;
1241
+ newFunction.shared = { ...type.shared };
1242
+ newFunction.shared.flags = flags;
1126
1243
  return newFunction;
1127
1244
  }
1128
1245
  FunctionType.cloneWithNewFlags = cloneWithNewFlags;
1129
- function cloneWithNewTypeVarScopeId(type, newScopeId, typeParameters, trackedSignatures) {
1246
+ function cloneWithNewTypeVarScopeId(type, newScopeId, newConstructorScopeId, typeParameters) {
1130
1247
  const newFunction = TypeBase.cloneType(type);
1131
1248
  // Make a shallow clone of the details.
1132
- newFunction.details = { ...type.details };
1133
- newFunction.details.typeVarScopeId = newScopeId;
1134
- newFunction.details.typeParameters = typeParameters;
1135
- newFunction.trackedSignatures = trackedSignatures;
1136
- FunctionType.addHigherOrderTypeVarScopeIds(newFunction, typeParameters.map((t) => t.scopeId));
1249
+ newFunction.shared = { ...type.shared };
1250
+ newFunction.shared.typeVarScopeId = newScopeId;
1251
+ newFunction.priv.constructorTypeVarScopeId = newConstructorScopeId;
1252
+ newFunction.shared.typeParameters = typeParameters;
1253
+ FunctionType.addHigherOrderTypeVarScopeIds(newFunction, typeParameters.map((t) => { var _a, _b; return (_b = (_a = t.priv.externalTypeVar) === null || _a === void 0 ? void 0 : _a.priv.scopeId) !== null && _b !== void 0 ? _b : t.priv.scopeId; }));
1137
1254
  return newFunction;
1138
1255
  }
1139
1256
  FunctionType.cloneWithNewTypeVarScopeId = cloneWithNewTypeVarScopeId;
1140
1257
  function cloneWithDocString(type, docString) {
1141
1258
  const newFunction = TypeBase.cloneType(type);
1142
1259
  // Make a shallow clone of the details.
1143
- newFunction.details = { ...type.details };
1144
- newFunction.details.docString = docString;
1260
+ newFunction.shared = { ...type.shared };
1261
+ newFunction.shared.docString = docString;
1145
1262
  return newFunction;
1146
1263
  }
1147
1264
  FunctionType.cloneWithDocString = cloneWithDocString;
1148
1265
  function cloneWithDeprecatedMessage(type, deprecatedMessage) {
1149
1266
  const newFunction = TypeBase.cloneType(type);
1150
1267
  // Make a shallow clone of the details.
1151
- newFunction.details = { ...type.details };
1152
- newFunction.details.deprecatedMessage = deprecatedMessage;
1268
+ newFunction.shared = { ...type.shared };
1269
+ newFunction.shared.deprecatedMessage = deprecatedMessage;
1153
1270
  return newFunction;
1154
1271
  }
1155
1272
  FunctionType.cloneWithDeprecatedMessage = cloneWithDeprecatedMessage;
@@ -1158,12 +1275,12 @@ var FunctionType;
1158
1275
  // *args and **kwargs parameters removed. If stripPositionOnlySeparator is true,
1159
1276
  // a trailing positional-only separator will be removed.
1160
1277
  function cloneRemoveParamSpecArgsKwargs(type, stripPositionOnlySeparator = false) {
1161
- const paramCount = type.details.parameters.length;
1278
+ const paramCount = type.shared.parameters.length;
1162
1279
  if (paramCount < 2) {
1163
1280
  return type;
1164
1281
  }
1165
- const argsParam = type.details.parameters[paramCount - 2];
1166
- const kwargsParam = type.details.parameters[paramCount - 1];
1282
+ const argsParam = type.shared.parameters[paramCount - 2];
1283
+ const kwargsParam = type.shared.parameters[paramCount - 1];
1167
1284
  if (argsParam.category !== 1 /* ParameterCategory.ArgsList */ ||
1168
1285
  kwargsParam.category !== 2 /* ParameterCategory.KwargsDict */) {
1169
1286
  return type;
@@ -1175,8 +1292,8 @@ var FunctionType;
1175
1292
  }
1176
1293
  const newFunction = TypeBase.cloneType(type);
1177
1294
  // Make a shallow clone of the details.
1178
- newFunction.details = { ...type.details };
1179
- const details = newFunction.details;
1295
+ newFunction.shared = { ...type.shared };
1296
+ const details = newFunction.shared;
1180
1297
  let paramsToDrop = 2;
1181
1298
  // If the last remaining parameter is a position-only separator, remove it as well.
1182
1299
  // Always remove it if it's the only remaining parameter.
@@ -1187,16 +1304,16 @@ var FunctionType;
1187
1304
  }
1188
1305
  // Remove the last parameters, which are the *args and **kwargs.
1189
1306
  details.parameters = details.parameters.slice(0, details.parameters.length - paramsToDrop);
1190
- if (type.specializedTypes) {
1191
- newFunction.specializedTypes = { ...type.specializedTypes };
1192
- newFunction.specializedTypes.parameterTypes = newFunction.specializedTypes.parameterTypes.slice(0, newFunction.specializedTypes.parameterTypes.length - paramsToDrop);
1193
- if (newFunction.specializedTypes.parameterDefaultArgs) {
1194
- newFunction.specializedTypes.parameterDefaultArgs =
1195
- newFunction.specializedTypes.parameterDefaultArgs.slice(0, newFunction.specializedTypes.parameterDefaultArgs.length - paramsToDrop);
1307
+ if (type.priv.specializedTypes) {
1308
+ newFunction.priv.specializedTypes = { ...type.priv.specializedTypes };
1309
+ newFunction.priv.specializedTypes.parameterTypes = newFunction.priv.specializedTypes.parameterTypes.slice(0, newFunction.priv.specializedTypes.parameterTypes.length - paramsToDrop);
1310
+ if (newFunction.priv.specializedTypes.parameterDefaultArgs) {
1311
+ newFunction.priv.specializedTypes.parameterDefaultArgs =
1312
+ newFunction.priv.specializedTypes.parameterDefaultArgs.slice(0, newFunction.priv.specializedTypes.parameterDefaultArgs.length - paramsToDrop);
1196
1313
  }
1197
1314
  }
1198
- if (type.inferredReturnType) {
1199
- newFunction.inferredReturnType = type.inferredReturnType;
1315
+ if (type.priv.inferredReturnType) {
1316
+ newFunction.priv.inferredReturnType = type.priv.inferredReturnType;
1200
1317
  }
1201
1318
  return newFunction;
1202
1319
  }
@@ -1204,7 +1321,7 @@ var FunctionType;
1204
1321
  // If the function ends with "*args: P.args, **kwargs: P.kwargs", this function
1205
1322
  // returns P. Otherwise, it returns undefined.
1206
1323
  function getParamSpecFromArgsKwargs(type) {
1207
- const params = type.details.parameters;
1324
+ const params = type.shared.parameters;
1208
1325
  if (params.length < 2) {
1209
1326
  return undefined;
1210
1327
  }
@@ -1212,28 +1329,18 @@ var FunctionType;
1212
1329
  const lastParam = params[params.length - 1];
1213
1330
  if (secondLastParam.category === 1 /* ParameterCategory.ArgsList */ &&
1214
1331
  isTypeVar(secondLastParam.type) &&
1215
- secondLastParam.type.paramSpecAccess === 'args' &&
1332
+ secondLastParam.type.priv.paramSpecAccess === 'args' &&
1216
1333
  lastParam.category === 2 /* ParameterCategory.KwargsDict */ &&
1217
1334
  isTypeVar(lastParam.type) &&
1218
- lastParam.type.paramSpecAccess === 'kwargs') {
1335
+ lastParam.type.priv.paramSpecAccess === 'kwargs') {
1219
1336
  return TypeVarType.cloneForParamSpecAccess(secondLastParam.type, /* access */ undefined);
1220
1337
  }
1221
1338
  return undefined;
1222
1339
  }
1223
1340
  FunctionType.getParamSpecFromArgsKwargs = getParamSpecFromArgsKwargs;
1224
1341
  function addParamSpecVariadics(type, paramSpec) {
1225
- FunctionType.addParameter(type, {
1226
- category: 1 /* ParameterCategory.ArgsList */,
1227
- name: 'args',
1228
- type: TypeVarType.cloneForParamSpecAccess(paramSpec, 'args'),
1229
- hasDeclaredType: true,
1230
- });
1231
- FunctionType.addParameter(type, {
1232
- category: 2 /* ParameterCategory.KwargsDict */,
1233
- name: 'kwargs',
1234
- type: TypeVarType.cloneForParamSpecAccess(paramSpec, 'kwargs'),
1235
- hasDeclaredType: true,
1236
- });
1342
+ FunctionType.addParameter(type, FunctionParam.create(1 /* ParameterCategory.ArgsList */, TypeVarType.cloneForParamSpecAccess(paramSpec, 'args'), FunctionParamFlags.TypeDeclared, 'args'));
1343
+ FunctionType.addParameter(type, FunctionParam.create(2 /* ParameterCategory.KwargsDict */, TypeVarType.cloneForParamSpecAccess(paramSpec, 'kwargs'), FunctionParamFlags.TypeDeclared, 'kwargs'));
1237
1344
  }
1238
1345
  FunctionType.addParamSpecVariadics = addParamSpecVariadics;
1239
1346
  function addDefaultParameters(type, useUnknown = false) {
@@ -1249,34 +1356,24 @@ var FunctionType;
1249
1356
  if (!Array.isArray(scopeIds)) {
1250
1357
  scopeIds = [scopeIds];
1251
1358
  }
1252
- if (!functionType.details.higherOrderTypeVarScopeIds) {
1253
- functionType.details.higherOrderTypeVarScopeIds = [];
1359
+ if (!functionType.priv.higherOrderTypeVarScopeIds) {
1360
+ functionType.priv.higherOrderTypeVarScopeIds = [];
1254
1361
  }
1255
1362
  // Add the scope IDs to the function if they're unique.
1256
1363
  scopeIds.forEach((scopeId) => {
1257
- if (!scopeId || scopeId === functionType.details.typeVarScopeId) {
1364
+ if (!scopeId || scopeId === functionType.shared.typeVarScopeId) {
1258
1365
  return;
1259
1366
  }
1260
- if (!functionType.details.higherOrderTypeVarScopeIds.some((id) => id === scopeId)) {
1261
- functionType.details.higherOrderTypeVarScopeIds.push(scopeId);
1367
+ if (!functionType.priv.higherOrderTypeVarScopeIds.some((id) => id === scopeId)) {
1368
+ functionType.priv.higherOrderTypeVarScopeIds.push(scopeId);
1262
1369
  }
1263
1370
  });
1264
1371
  }
1265
1372
  FunctionType.addHigherOrderTypeVarScopeIds = addHigherOrderTypeVarScopeIds;
1266
1373
  function getDefaultParameters(useUnknown = false) {
1267
1374
  return [
1268
- {
1269
- category: 1 /* ParameterCategory.ArgsList */,
1270
- name: 'args',
1271
- type: useUnknown ? UnknownType.create() : AnyType.create(),
1272
- hasDeclaredType: !useUnknown,
1273
- },
1274
- {
1275
- category: 2 /* ParameterCategory.KwargsDict */,
1276
- name: 'kwargs',
1277
- type: useUnknown ? UnknownType.create() : AnyType.create(),
1278
- hasDeclaredType: !useUnknown,
1279
- },
1375
+ FunctionParam.create(1 /* ParameterCategory.ArgsList */, useUnknown ? UnknownType.create() : AnyType.create(), useUnknown ? FunctionParamFlags.None : FunctionParamFlags.TypeDeclared, 'args'),
1376
+ FunctionParam.create(2 /* ParameterCategory.KwargsDict */, useUnknown ? UnknownType.create() : AnyType.create(), useUnknown ? FunctionParamFlags.None : FunctionParamFlags.TypeDeclared, 'kwargs'),
1280
1377
  ];
1281
1378
  }
1282
1379
  FunctionType.getDefaultParameters = getDefaultParameters;
@@ -1284,8 +1381,8 @@ var FunctionType;
1284
1381
  function hasDefaultParameters(functionType) {
1285
1382
  let sawArgs = false;
1286
1383
  let sawKwargs = false;
1287
- for (let i = 0; i < functionType.details.parameters.length; i++) {
1288
- const param = functionType.details.parameters[i];
1384
+ for (let i = 0; i < functionType.shared.parameters.length; i++) {
1385
+ const param = functionType.shared.parameters[i];
1289
1386
  // Ignore nameless separator parameters.
1290
1387
  if (!param.name) {
1291
1388
  continue;
@@ -1307,7 +1404,7 @@ var FunctionType;
1307
1404
  }
1308
1405
  FunctionType.hasDefaultParameters = hasDefaultParameters;
1309
1406
  function isInstanceMethod(type) {
1310
- return ((type.details.flags &
1407
+ return ((type.shared.flags &
1311
1408
  (1 /* FunctionTypeFlags.ConstructorMethod */ |
1312
1409
  4 /* FunctionTypeFlags.StaticMethod */ |
1313
1410
  2 /* FunctionTypeFlags.ClassMethod */)) ===
@@ -1315,128 +1412,134 @@ var FunctionType;
1315
1412
  }
1316
1413
  FunctionType.isInstanceMethod = isInstanceMethod;
1317
1414
  function isConstructorMethod(type) {
1318
- return (type.details.flags & 1 /* FunctionTypeFlags.ConstructorMethod */) !== 0;
1415
+ return (type.shared.flags & 1 /* FunctionTypeFlags.ConstructorMethod */) !== 0;
1319
1416
  }
1320
1417
  FunctionType.isConstructorMethod = isConstructorMethod;
1321
1418
  function isStaticMethod(type) {
1322
- return (type.details.flags & 4 /* FunctionTypeFlags.StaticMethod */) !== 0;
1419
+ return (type.shared.flags & 4 /* FunctionTypeFlags.StaticMethod */) !== 0;
1323
1420
  }
1324
1421
  FunctionType.isStaticMethod = isStaticMethod;
1325
1422
  function isClassMethod(type) {
1326
- return (type.details.flags & 2 /* FunctionTypeFlags.ClassMethod */) !== 0;
1423
+ return (type.shared.flags & 2 /* FunctionTypeFlags.ClassMethod */) !== 0;
1327
1424
  }
1328
1425
  FunctionType.isClassMethod = isClassMethod;
1329
1426
  function isAbstractMethod(type) {
1330
- return (type.details.flags & 8 /* FunctionTypeFlags.AbstractMethod */) !== 0;
1427
+ return (type.shared.flags & 8 /* FunctionTypeFlags.AbstractMethod */) !== 0;
1331
1428
  }
1332
1429
  FunctionType.isAbstractMethod = isAbstractMethod;
1333
1430
  function isGenerator(type) {
1334
- return (type.details.flags & 16 /* FunctionTypeFlags.Generator */) !== 0;
1431
+ return (type.shared.flags & 16 /* FunctionTypeFlags.Generator */) !== 0;
1335
1432
  }
1336
1433
  FunctionType.isGenerator = isGenerator;
1337
1434
  function isSynthesizedMethod(type) {
1338
- return (type.details.flags & 64 /* FunctionTypeFlags.SynthesizedMethod */) !== 0;
1435
+ return (type.shared.flags & 64 /* FunctionTypeFlags.SynthesizedMethod */) !== 0;
1339
1436
  }
1340
1437
  FunctionType.isSynthesizedMethod = isSynthesizedMethod;
1341
1438
  function isTypeCheckOnly(type) {
1342
- return (type.details.flags & 128 /* FunctionTypeFlags.TypeCheckOnly */) !== 0;
1439
+ return (type.shared.flags & 128 /* FunctionTypeFlags.TypeCheckOnly */) !== 0;
1343
1440
  }
1344
1441
  FunctionType.isTypeCheckOnly = isTypeCheckOnly;
1345
1442
  function isOverloaded(type) {
1346
- return (type.details.flags & 256 /* FunctionTypeFlags.Overloaded */) !== 0;
1443
+ return (type.shared.flags & 256 /* FunctionTypeFlags.Overloaded */) !== 0;
1347
1444
  }
1348
1445
  FunctionType.isOverloaded = isOverloaded;
1349
1446
  function isDefaultParameterCheckDisabled(type) {
1350
- return (type.details.flags & 32 /* FunctionTypeFlags.DisableDefaultChecks */) !== 0;
1447
+ return (type.shared.flags & 32 /* FunctionTypeFlags.DisableDefaultChecks */) !== 0;
1351
1448
  }
1352
1449
  FunctionType.isDefaultParameterCheckDisabled = isDefaultParameterCheckDisabled;
1353
1450
  function isAsync(type) {
1354
- return (type.details.flags & 512 /* FunctionTypeFlags.Async */) !== 0;
1451
+ return (type.shared.flags & 512 /* FunctionTypeFlags.Async */) !== 0;
1355
1452
  }
1356
1453
  FunctionType.isAsync = isAsync;
1357
1454
  function isStubDefinition(type) {
1358
- return (type.details.flags & 2048 /* FunctionTypeFlags.StubDefinition */) !== 0;
1455
+ return (type.shared.flags & 2048 /* FunctionTypeFlags.StubDefinition */) !== 0;
1359
1456
  }
1360
1457
  FunctionType.isStubDefinition = isStubDefinition;
1361
1458
  function isPyTypedDefinition(type) {
1362
- return (type.details.flags & 4096 /* FunctionTypeFlags.PyTypedDefinition */) !== 0;
1459
+ return (type.shared.flags & 4096 /* FunctionTypeFlags.PyTypedDefinition */) !== 0;
1363
1460
  }
1364
1461
  FunctionType.isPyTypedDefinition = isPyTypedDefinition;
1365
1462
  function isFinal(type) {
1366
- return (type.details.flags & 8192 /* FunctionTypeFlags.Final */) !== 0;
1463
+ return (type.shared.flags & 8192 /* FunctionTypeFlags.Final */) !== 0;
1367
1464
  }
1368
1465
  FunctionType.isFinal = isFinal;
1369
1466
  function hasUnannotatedParams(type) {
1370
- return (type.details.flags & 16384 /* FunctionTypeFlags.UnannotatedParams */) !== 0;
1467
+ return (type.shared.flags & 16384 /* FunctionTypeFlags.UnannotatedParams */) !== 0;
1371
1468
  }
1372
1469
  FunctionType.hasUnannotatedParams = hasUnannotatedParams;
1373
1470
  function isGradualCallableForm(type) {
1374
- return (type.details.flags & 32768 /* FunctionTypeFlags.GradualCallableForm */) !== 0;
1471
+ return (type.shared.flags & 32768 /* FunctionTypeFlags.GradualCallableForm */) !== 0;
1375
1472
  }
1376
1473
  FunctionType.isGradualCallableForm = isGradualCallableForm;
1377
1474
  function isParamSpecValue(type) {
1378
- return (type.details.flags & 65536 /* FunctionTypeFlags.ParamSpecValue */) !== 0;
1475
+ return (type.shared.flags & 65536 /* FunctionTypeFlags.ParamSpecValue */) !== 0;
1379
1476
  }
1380
1477
  FunctionType.isParamSpecValue = isParamSpecValue;
1381
1478
  function isPartiallyEvaluated(type) {
1382
- return !!(type.details.flags & 131072 /* FunctionTypeFlags.PartiallyEvaluated */);
1479
+ return !!(type.shared.flags & 131072 /* FunctionTypeFlags.PartiallyEvaluated */);
1383
1480
  }
1384
1481
  FunctionType.isPartiallyEvaluated = isPartiallyEvaluated;
1385
1482
  function isOverridden(type) {
1386
- return !!(type.details.flags & 262144 /* FunctionTypeFlags.Overridden */);
1483
+ return !!(type.shared.flags & 262144 /* FunctionTypeFlags.Overridden */);
1387
1484
  }
1388
1485
  FunctionType.isOverridden = isOverridden;
1486
+ function isBuiltIn(type, name) {
1487
+ if (!(type.shared.flags & 1048576 /* FunctionTypeFlags.BuiltIn */)) {
1488
+ return false;
1489
+ }
1490
+ if (name !== undefined) {
1491
+ const functionArray = Array.isArray(name) ? name : [name];
1492
+ return functionArray.some((name) => name === type.shared.name);
1493
+ }
1494
+ return true;
1495
+ }
1496
+ FunctionType.isBuiltIn = isBuiltIn;
1389
1497
  function getEffectiveParameterType(type, index) {
1390
- (0, debug_1.assert)(index < type.details.parameters.length, 'Parameter types array overflow');
1391
- if (type.specializedTypes && index < type.specializedTypes.parameterTypes.length) {
1392
- return type.specializedTypes.parameterTypes[index];
1498
+ (0, debug_1.assert)(index < type.shared.parameters.length, 'Parameter types array overflow');
1499
+ if (type.priv.specializedTypes && index < type.priv.specializedTypes.parameterTypes.length) {
1500
+ return type.priv.specializedTypes.parameterTypes[index];
1393
1501
  }
1394
- return type.details.parameters[index].type;
1502
+ return type.shared.parameters[index].type;
1395
1503
  }
1396
1504
  FunctionType.getEffectiveParameterType = getEffectiveParameterType;
1397
1505
  function getEffectiveParameterDefaultArgType(type, index) {
1398
1506
  var _a;
1399
- (0, debug_1.assert)(index < type.details.parameters.length, 'Parameter types array overflow');
1400
- if (((_a = type.specializedTypes) === null || _a === void 0 ? void 0 : _a.parameterDefaultArgs) && index < type.specializedTypes.parameterDefaultArgs.length) {
1401
- const defaultArgType = type.specializedTypes.parameterDefaultArgs[index];
1507
+ (0, debug_1.assert)(index < type.shared.parameters.length, 'Parameter types array overflow');
1508
+ if (((_a = type.priv.specializedTypes) === null || _a === void 0 ? void 0 : _a.parameterDefaultArgs) &&
1509
+ index < type.priv.specializedTypes.parameterDefaultArgs.length) {
1510
+ const defaultArgType = type.priv.specializedTypes.parameterDefaultArgs[index];
1402
1511
  if (defaultArgType) {
1403
1512
  return defaultArgType;
1404
1513
  }
1405
1514
  }
1406
- return type.details.parameters[index].defaultType;
1515
+ return type.shared.parameters[index].defaultType;
1407
1516
  }
1408
1517
  FunctionType.getEffectiveParameterDefaultArgType = getEffectiveParameterDefaultArgType;
1409
1518
  function addParameter(type, param) {
1410
- type.details.parameters.push(param);
1411
- if (type.specializedTypes) {
1412
- type.specializedTypes.parameterTypes.push(param.type);
1519
+ type.shared.parameters.push(param);
1520
+ if (type.priv.specializedTypes) {
1521
+ type.priv.specializedTypes.parameterTypes.push(param.type);
1413
1522
  }
1414
1523
  }
1415
1524
  FunctionType.addParameter = addParameter;
1416
1525
  function addPositionOnlyParameterSeparator(type) {
1417
- addParameter(type, {
1418
- category: 0 /* ParameterCategory.Simple */,
1419
- type: AnyType.create(),
1420
- });
1526
+ addParameter(type, FunctionParam.create(0 /* ParameterCategory.Simple */, AnyType.create()));
1421
1527
  }
1422
1528
  FunctionType.addPositionOnlyParameterSeparator = addPositionOnlyParameterSeparator;
1423
1529
  function addKeywordOnlyParameterSeparator(type) {
1424
- addParameter(type, {
1425
- category: 1 /* ParameterCategory.ArgsList */,
1426
- type: AnyType.create(),
1427
- });
1530
+ addParameter(type, FunctionParam.create(1 /* ParameterCategory.ArgsList */, AnyType.create()));
1428
1531
  }
1429
1532
  FunctionType.addKeywordOnlyParameterSeparator = addKeywordOnlyParameterSeparator;
1430
1533
  function getEffectiveReturnType(type, includeInferred = true) {
1431
1534
  var _a;
1432
- if ((_a = type.specializedTypes) === null || _a === void 0 ? void 0 : _a.returnType) {
1433
- return type.specializedTypes.returnType;
1535
+ if ((_a = type.priv.specializedTypes) === null || _a === void 0 ? void 0 : _a.returnType) {
1536
+ return type.priv.specializedTypes.returnType;
1434
1537
  }
1435
- if (type.details.declaredReturnType) {
1436
- return type.details.declaredReturnType;
1538
+ if (type.shared.declaredReturnType) {
1539
+ return type.shared.declaredReturnType;
1437
1540
  }
1438
1541
  if (includeInferred) {
1439
- return type.inferredReturnType;
1542
+ return type.priv.inferredReturnType;
1440
1543
  }
1441
1544
  return undefined;
1442
1545
  }
@@ -1447,8 +1550,13 @@ var OverloadedFunctionType;
1447
1550
  function create(overloads) {
1448
1551
  const newType = {
1449
1552
  category: 5 /* TypeCategory.OverloadedFunction */,
1450
- overloads: [],
1451
1553
  flags: 2 /* TypeFlags.Instance */,
1554
+ props: undefined,
1555
+ cached: undefined,
1556
+ shared: undefined,
1557
+ priv: {
1558
+ overloads: [],
1559
+ },
1452
1560
  };
1453
1561
  overloads.forEach((overload) => {
1454
1562
  OverloadedFunctionType.addOverload(newType, overload);
@@ -1458,16 +1566,16 @@ var OverloadedFunctionType;
1458
1566
  OverloadedFunctionType.create = create;
1459
1567
  // Adds a new overload or an implementation.
1460
1568
  function addOverload(type, functionType) {
1461
- functionType.overloaded = type;
1462
- type.overloads.push(functionType);
1569
+ functionType.priv.overloaded = type;
1570
+ type.priv.overloads.push(functionType);
1463
1571
  }
1464
1572
  OverloadedFunctionType.addOverload = addOverload;
1465
1573
  function getOverloads(type) {
1466
- return type.overloads.filter((func) => FunctionType.isOverloaded(func));
1574
+ return type.priv.overloads.filter((func) => FunctionType.isOverloaded(func));
1467
1575
  }
1468
1576
  OverloadedFunctionType.getOverloads = getOverloads;
1469
1577
  function getImplementation(type) {
1470
- return type.overloads.find((func) => !FunctionType.isOverloaded(func));
1578
+ return type.priv.overloads.find((func) => !FunctionType.isOverloaded(func));
1471
1579
  }
1472
1580
  OverloadedFunctionType.getImplementation = getImplementation;
1473
1581
  })(OverloadedFunctionType || (exports.OverloadedFunctionType = OverloadedFunctionType = {}));
@@ -1476,12 +1584,18 @@ var NeverType;
1476
1584
  const _neverInstance = {
1477
1585
  category: 3 /* TypeCategory.Never */,
1478
1586
  flags: 2 /* TypeFlags.Instance */ | 1 /* TypeFlags.Instantiable */,
1479
- isNoReturn: false,
1587
+ props: undefined,
1588
+ cached: undefined,
1589
+ shared: undefined,
1590
+ priv: { isNoReturn: false },
1480
1591
  };
1481
1592
  const _noReturnInstance = {
1482
1593
  category: 3 /* TypeCategory.Never */,
1483
1594
  flags: 2 /* TypeFlags.Instance */ | 1 /* TypeFlags.Instantiable */,
1484
- isNoReturn: true,
1595
+ props: undefined,
1596
+ cached: undefined,
1597
+ shared: undefined,
1598
+ priv: { isNoReturn: true },
1485
1599
  };
1486
1600
  function createNever() {
1487
1601
  return _neverInstance;
@@ -1492,11 +1606,12 @@ var NeverType;
1492
1606
  }
1493
1607
  NeverType.createNoReturn = createNoReturn;
1494
1608
  function convertToInstance(type) {
1609
+ var _a;
1495
1610
  // Remove the "special form" if present. Otherwise return the existing type.
1496
- if (!type.specialForm) {
1611
+ if (!((_a = type.props) === null || _a === void 0 ? void 0 : _a.specialForm)) {
1497
1612
  return type;
1498
1613
  }
1499
- return type.isNoReturn ? NeverType.createNoReturn() : NeverType.createNever();
1614
+ return type.priv.isNoReturn ? NeverType.createNoReturn() : NeverType.createNever();
1500
1615
  }
1501
1616
  NeverType.convertToInstance = convertToInstance;
1502
1617
  })(NeverType || (exports.NeverType = NeverType = {}));
@@ -1504,18 +1619,27 @@ var AnyType;
1504
1619
  (function (AnyType) {
1505
1620
  const _anyInstanceSpecialForm = {
1506
1621
  category: 2 /* TypeCategory.Any */,
1507
- isEllipsis: false,
1508
1622
  flags: 2 /* TypeFlags.Instance */ | 1 /* TypeFlags.Instantiable */,
1623
+ props: undefined,
1624
+ cached: undefined,
1625
+ shared: undefined,
1626
+ priv: { isEllipsis: false },
1509
1627
  };
1510
1628
  const _anyInstance = {
1511
1629
  category: 2 /* TypeCategory.Any */,
1512
- isEllipsis: false,
1513
1630
  flags: 2 /* TypeFlags.Instance */ | 1 /* TypeFlags.Instantiable */,
1631
+ props: undefined,
1632
+ cached: undefined,
1633
+ shared: undefined,
1634
+ priv: { isEllipsis: false },
1514
1635
  };
1515
1636
  const _ellipsisInstance = {
1516
1637
  category: 2 /* TypeCategory.Any */,
1517
- isEllipsis: true,
1518
1638
  flags: 2 /* TypeFlags.Instance */ | 1 /* TypeFlags.Instantiable */,
1639
+ props: undefined,
1640
+ cached: undefined,
1641
+ shared: undefined,
1642
+ priv: { isEllipsis: true },
1519
1643
  };
1520
1644
  function create(isEllipsis = false) {
1521
1645
  return isEllipsis ? _ellipsisInstance : _anyInstance;
@@ -1528,8 +1652,9 @@ var AnyType;
1528
1652
  })(AnyType || (exports.AnyType = AnyType = {}));
1529
1653
  (function (AnyType) {
1530
1654
  function convertToInstance(type) {
1655
+ var _a;
1531
1656
  // Remove the "special form" if present. Otherwise return the existing type.
1532
- return type.specialForm ? AnyType.create() : type;
1657
+ return ((_a = type.props) === null || _a === void 0 ? void 0 : _a.specialForm) ? AnyType.create() : type;
1533
1658
  }
1534
1659
  AnyType.convertToInstance = convertToInstance;
1535
1660
  })(AnyType || (exports.AnyType = AnyType = {}));
@@ -1554,10 +1679,10 @@ var TypeCondition;
1554
1679
  }
1555
1680
  TypeCondition.combine = combine;
1556
1681
  function _compare(c1, c2) {
1557
- if (c1.typeVar.details.name < c2.typeVar.details.name) {
1682
+ if (c1.typeVar.shared.name < c2.typeVar.shared.name) {
1558
1683
  return -1;
1559
1684
  }
1560
- else if (c1.typeVar.details.name > c2.typeVar.details.name) {
1685
+ else if (c1.typeVar.shared.name > c2.typeVar.shared.name) {
1561
1686
  return 1;
1562
1687
  }
1563
1688
  if (c1.constraintIndex < c2.constraintIndex) {
@@ -1575,7 +1700,7 @@ var TypeCondition;
1575
1700
  if (!conditions2 || conditions1.length !== conditions2.length) {
1576
1701
  return false;
1577
1702
  }
1578
- return (conditions1.find((c1, index) => c1.typeVar.nameWithScope !== conditions2[index].typeVar.nameWithScope ||
1703
+ return (conditions1.find((c1, index) => c1.typeVar.priv.nameWithScope !== conditions2[index].typeVar.priv.nameWithScope ||
1579
1704
  c1.constraintIndex !== conditions2[index].constraintIndex) === undefined);
1580
1705
  }
1581
1706
  TypeCondition.isSame = isSame;
@@ -1590,7 +1715,7 @@ var TypeCondition;
1590
1715
  for (const c1 of conditions1) {
1591
1716
  let foundTypeVarMatch = false;
1592
1717
  const exactMatch = conditions2.find((c2) => {
1593
- if (c1.typeVar.nameWithScope === c2.typeVar.nameWithScope) {
1718
+ if (c1.typeVar.priv.nameWithScope === c2.typeVar.priv.nameWithScope) {
1594
1719
  foundTypeVarMatch = true;
1595
1720
  return c1.constraintIndex === c2.constraintIndex;
1596
1721
  }
@@ -1609,46 +1734,64 @@ var UnionType;
1609
1734
  function create() {
1610
1735
  const newUnionType = {
1611
1736
  category: 8 /* TypeCategory.Union */,
1612
- subtypes: [],
1613
- literalInstances: {},
1614
- literalClasses: {},
1615
1737
  flags: 2 /* TypeFlags.Instance */ | 1 /* TypeFlags.Instantiable */,
1738
+ props: undefined,
1739
+ cached: undefined,
1740
+ shared: undefined,
1741
+ priv: {
1742
+ subtypes: [],
1743
+ literalInstances: {
1744
+ literalStrMap: undefined,
1745
+ literalIntMap: undefined,
1746
+ literalEnumMap: undefined,
1747
+ },
1748
+ literalClasses: {
1749
+ literalStrMap: undefined,
1750
+ literalIntMap: undefined,
1751
+ literalEnumMap: undefined,
1752
+ },
1753
+ typeAliasSources: undefined,
1754
+ includesRecursiveTypeAlias: false,
1755
+ },
1616
1756
  };
1617
1757
  return newUnionType;
1618
1758
  }
1619
1759
  UnionType.create = create;
1620
1760
  function addType(unionType, newType) {
1761
+ var _a, _b;
1621
1762
  // If we're adding a string, integer or enum literal, add it to the
1622
1763
  // corresponding literal map to speed up some operations. It's not
1623
1764
  // uncommon for unions to contain hundreds of literals.
1624
- if (isClass(newType) && newType.literalValue !== undefined && newType.condition === undefined) {
1625
- const literalMaps = isClassInstance(newType) ? unionType.literalInstances : unionType.literalClasses;
1765
+ if (isClass(newType) && newType.priv.literalValue !== undefined && !((_a = newType.props) === null || _a === void 0 ? void 0 : _a.condition)) {
1766
+ const literalMaps = isClassInstance(newType)
1767
+ ? unionType.priv.literalInstances
1768
+ : unionType.priv.literalClasses;
1626
1769
  if (ClassType.isBuiltIn(newType, 'str')) {
1627
1770
  if (literalMaps.literalStrMap === undefined) {
1628
1771
  literalMaps.literalStrMap = new Map();
1629
1772
  }
1630
- literalMaps.literalStrMap.set(newType.literalValue, newType);
1773
+ literalMaps.literalStrMap.set(newType.priv.literalValue, newType);
1631
1774
  }
1632
1775
  else if (ClassType.isBuiltIn(newType, 'int')) {
1633
1776
  if (literalMaps.literalIntMap === undefined) {
1634
1777
  literalMaps.literalIntMap = new Map();
1635
1778
  }
1636
- literalMaps.literalIntMap.set(newType.literalValue, newType);
1779
+ literalMaps.literalIntMap.set(newType.priv.literalValue, newType);
1637
1780
  }
1638
1781
  else if (ClassType.isEnumClass(newType)) {
1639
1782
  if (literalMaps.literalEnumMap === undefined) {
1640
1783
  literalMaps.literalEnumMap = new Map();
1641
1784
  }
1642
- const enumLiteral = newType.literalValue;
1785
+ const enumLiteral = newType.priv.literalValue;
1643
1786
  literalMaps.literalEnumMap.set(enumLiteral.getName(), newType);
1644
1787
  }
1645
1788
  }
1646
1789
  unionType.flags &= newType.flags;
1647
- unionType.subtypes.push(newType);
1648
- if (isTypeVar(newType) && newType.details.recursiveTypeAliasName) {
1790
+ unionType.priv.subtypes.push(newType);
1791
+ if (isTypeVar(newType) && ((_b = newType.shared.recursiveAlias) === null || _b === void 0 ? void 0 : _b.name)) {
1649
1792
  // Note that at least one recursive type alias was included in
1650
1793
  // this union. We'll need to expand it before the union is used.
1651
- unionType.includesRecursiveTypeAlias = true;
1794
+ unionType.priv.includesRecursiveTypeAlias = true;
1652
1795
  }
1653
1796
  }
1654
1797
  UnionType.addType = addType;
@@ -1656,22 +1799,25 @@ var UnionType;
1656
1799
  // the method skips any subtype indexes that are in the set and adds a found index to
1657
1800
  // the exclusion set. This speeds up union type comparisons.
1658
1801
  function containsType(unionType, subtype, exclusionSet, recursionCount = 0) {
1802
+ var _a;
1659
1803
  // Handle string literals as a special case because unions can sometimes
1660
1804
  // contain hundreds of string literal types.
1661
- if (isClass(subtype) && subtype.condition === undefined && subtype.literalValue !== undefined) {
1662
- const literalMaps = isClassInstance(subtype) ? unionType.literalInstances : unionType.literalClasses;
1805
+ if (isClass(subtype) && ((_a = subtype.props) === null || _a === void 0 ? void 0 : _a.condition) === undefined && subtype.priv.literalValue !== undefined) {
1806
+ const literalMaps = isClassInstance(subtype)
1807
+ ? unionType.priv.literalInstances
1808
+ : unionType.priv.literalClasses;
1663
1809
  if (ClassType.isBuiltIn(subtype, 'str') && literalMaps.literalStrMap !== undefined) {
1664
- return literalMaps.literalStrMap.has(subtype.literalValue);
1810
+ return literalMaps.literalStrMap.has(subtype.priv.literalValue);
1665
1811
  }
1666
1812
  else if (ClassType.isBuiltIn(subtype, 'int') && literalMaps.literalIntMap !== undefined) {
1667
- return literalMaps.literalIntMap.has(subtype.literalValue);
1813
+ return literalMaps.literalIntMap.has(subtype.priv.literalValue);
1668
1814
  }
1669
1815
  else if (ClassType.isEnumClass(subtype) && literalMaps.literalEnumMap !== undefined) {
1670
- const enumLiteral = subtype.literalValue;
1816
+ const enumLiteral = subtype.priv.literalValue;
1671
1817
  return literalMaps.literalEnumMap.has(enumLiteral.getName());
1672
1818
  }
1673
1819
  }
1674
- const foundIndex = unionType.subtypes.findIndex((t, i) => {
1820
+ const foundIndex = unionType.priv.subtypes.findIndex((t, i) => {
1675
1821
  if (exclusionSet === null || exclusionSet === void 0 ? void 0 : exclusionSet.has(i)) {
1676
1822
  return false;
1677
1823
  }
@@ -1685,14 +1831,17 @@ var UnionType;
1685
1831
  }
1686
1832
  UnionType.containsType = containsType;
1687
1833
  function addTypeAliasSource(unionType, typeAliasSource) {
1834
+ var _a;
1688
1835
  if (typeAliasSource.category === 8 /* TypeCategory.Union */) {
1689
- const sourcesToAdd = typeAliasSource.typeAliasInfo ? [typeAliasSource] : typeAliasSource.typeAliasSources;
1836
+ const sourcesToAdd = ((_a = typeAliasSource.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo)
1837
+ ? [typeAliasSource]
1838
+ : typeAliasSource.priv.typeAliasSources;
1690
1839
  if (sourcesToAdd) {
1691
- if (!unionType.typeAliasSources) {
1692
- unionType.typeAliasSources = new Set();
1840
+ if (!unionType.priv.typeAliasSources) {
1841
+ unionType.priv.typeAliasSources = new Set();
1693
1842
  }
1694
1843
  sourcesToAdd.forEach((source) => {
1695
- unionType.typeAliasSources.add(source);
1844
+ unionType.priv.typeAliasSources.add(source);
1696
1845
  });
1697
1846
  }
1698
1847
  }
@@ -1724,13 +1873,18 @@ var TypeVarType;
1724
1873
  }
1725
1874
  TypeVarType.createInstantiable = createInstantiable;
1726
1875
  function cloneAsInstance(type) {
1727
- var _a;
1876
+ var _a, _b;
1728
1877
  (0, debug_1.assert)(TypeBase.isInstantiable(type));
1729
1878
  if ((_a = type.cached) === null || _a === void 0 ? void 0 : _a.typeBaseInstanceType) {
1730
1879
  return type.cached.typeBaseInstanceType;
1731
1880
  }
1732
1881
  const newInstance = TypeBase.cloneTypeAsInstance(type, /* cache */ true);
1733
- delete newInstance.specialForm;
1882
+ if ((_b = newInstance.props) === null || _b === void 0 ? void 0 : _b.specialForm) {
1883
+ TypeBase.setSpecialForm(newInstance, undefined);
1884
+ }
1885
+ if (newInstance.priv.externalTypeVar) {
1886
+ newInstance.priv.externalTypeVar = TypeVarType.cloneAsInstance(newInstance.priv.externalTypeVar);
1887
+ }
1734
1888
  return newInstance;
1735
1889
  }
1736
1890
  TypeVarType.cloneAsInstance = cloneAsInstance;
@@ -1740,41 +1894,50 @@ var TypeVarType;
1740
1894
  return type.cached.typeBaseInstantiableType;
1741
1895
  }
1742
1896
  const newInstance = TypeBase.cloneTypeAsInstantiable(type, /* cache */ true);
1897
+ if (newInstance.priv.externalTypeVar) {
1898
+ newInstance.priv.externalTypeVar = TypeVarType.cloneAsInstantiable(newInstance.priv.externalTypeVar);
1899
+ }
1743
1900
  return newInstance;
1744
1901
  }
1745
1902
  TypeVarType.cloneAsInstantiable = cloneAsInstantiable;
1746
1903
  function cloneForNewName(type, name) {
1747
1904
  const newInstance = TypeBase.cloneType(type);
1748
- newInstance.details = { ...type.details };
1749
- newInstance.details.name = name;
1750
- if (newInstance.scopeId) {
1751
- newInstance.nameWithScope = makeNameWithScope(name, newInstance.scopeId);
1905
+ newInstance.shared = { ...type.shared };
1906
+ newInstance.shared.name = name;
1907
+ if (newInstance.priv.scopeId) {
1908
+ newInstance.priv.nameWithScope = makeNameWithScope(name, newInstance.priv.scopeId);
1752
1909
  }
1753
1910
  return newInstance;
1754
1911
  }
1755
1912
  TypeVarType.cloneForNewName = cloneForNewName;
1756
1913
  function cloneForScopeId(type, scopeId, scopeName, scopeType) {
1757
1914
  const newInstance = TypeBase.cloneType(type);
1758
- newInstance.nameWithScope = makeNameWithScope(type.details.name, scopeId);
1759
- newInstance.scopeId = scopeId;
1760
- newInstance.scopeName = scopeName;
1761
- newInstance.scopeType = scopeType;
1915
+ newInstance.priv.nameWithScope = makeNameWithScope(type.shared.name, scopeId);
1916
+ newInstance.priv.scopeId = scopeId;
1917
+ newInstance.priv.scopeName = scopeName;
1918
+ newInstance.priv.scopeType = scopeType;
1762
1919
  return newInstance;
1763
1920
  }
1764
1921
  TypeVarType.cloneForScopeId = cloneForScopeId;
1765
1922
  function cloneForUnpacked(type, isInUnion = false) {
1766
- (0, debug_1.assert)(type.details.isVariadic);
1923
+ (0, debug_1.assert)(type.shared.isVariadic);
1767
1924
  const newInstance = TypeBase.cloneType(type);
1768
- newInstance.isVariadicUnpacked = true;
1769
- newInstance.isVariadicInUnion = isInUnion;
1925
+ newInstance.priv.isVariadicUnpacked = true;
1926
+ newInstance.priv.isVariadicInUnion = isInUnion;
1927
+ if (newInstance.priv.externalTypeVar) {
1928
+ newInstance.priv.externalTypeVar = TypeVarType.cloneForUnpacked(newInstance.priv.externalTypeVar, isInUnion);
1929
+ }
1770
1930
  return newInstance;
1771
1931
  }
1772
1932
  TypeVarType.cloneForUnpacked = cloneForUnpacked;
1773
1933
  function cloneForPacked(type) {
1774
- (0, debug_1.assert)(type.details.isVariadic);
1934
+ (0, debug_1.assert)(type.shared.isVariadic);
1775
1935
  const newInstance = TypeBase.cloneType(type);
1776
- newInstance.isVariadicUnpacked = false;
1777
- newInstance.isVariadicInUnion = false;
1936
+ newInstance.priv.isVariadicUnpacked = false;
1937
+ newInstance.priv.isVariadicInUnion = false;
1938
+ if (newInstance.priv.externalTypeVar) {
1939
+ newInstance.priv.externalTypeVar = TypeVarType.cloneForPacked(newInstance.priv.externalTypeVar);
1940
+ }
1778
1941
  return newInstance;
1779
1942
  }
1780
1943
  TypeVarType.cloneForPacked = cloneForPacked;
@@ -1782,55 +1945,55 @@ var TypeVarType;
1782
1945
  // and no bound or constraints. ParamSpecs and variadics are left
1783
1946
  // unmodified. So are auto-variant type variables.
1784
1947
  function cloneAsInvariant(type) {
1785
- if (type.details.isParamSpec || type.details.isVariadic) {
1948
+ if (type.shared.isParamSpec || type.shared.isVariadic) {
1786
1949
  return type;
1787
1950
  }
1788
- if (type.details.declaredVariance === 0 /* Variance.Auto */) {
1951
+ if (type.shared.declaredVariance === 0 /* Variance.Auto */) {
1789
1952
  return type;
1790
1953
  }
1791
- if (type.details.declaredVariance === 2 /* Variance.Invariant */) {
1792
- if (type.details.boundType === undefined && type.details.constraints.length === 0) {
1954
+ if (type.shared.declaredVariance === 2 /* Variance.Invariant */) {
1955
+ if (type.shared.boundType === undefined && type.shared.constraints.length === 0) {
1793
1956
  return type;
1794
1957
  }
1795
1958
  }
1796
1959
  const newInstance = TypeBase.cloneType(type);
1797
- newInstance.details = { ...newInstance.details };
1798
- newInstance.details.declaredVariance = 2 /* Variance.Invariant */;
1799
- newInstance.details.boundType = undefined;
1800
- newInstance.details.constraints = [];
1960
+ newInstance.shared = { ...newInstance.shared };
1961
+ newInstance.shared.declaredVariance = 2 /* Variance.Invariant */;
1962
+ newInstance.shared.boundType = undefined;
1963
+ newInstance.shared.constraints = [];
1801
1964
  return newInstance;
1802
1965
  }
1803
1966
  TypeVarType.cloneAsInvariant = cloneAsInvariant;
1804
1967
  function cloneForParamSpecAccess(type, access) {
1805
1968
  const newInstance = TypeBase.cloneType(type);
1806
- newInstance.paramSpecAccess = access;
1969
+ newInstance.priv.paramSpecAccess = access;
1807
1970
  return newInstance;
1808
1971
  }
1809
1972
  TypeVarType.cloneForParamSpecAccess = cloneForParamSpecAccess;
1810
1973
  function cloneAsSpecializedSelf(type, specializedBoundType) {
1811
- (0, debug_1.assert)(type.details.isSynthesizedSelf);
1974
+ (0, debug_1.assert)(type.shared.isSynthesizedSelf);
1812
1975
  const newInstance = TypeBase.cloneType(type);
1813
- newInstance.details = { ...newInstance.details };
1814
- newInstance.details.boundType = specializedBoundType;
1976
+ newInstance.shared = { ...newInstance.shared };
1977
+ newInstance.shared.boundType = specializedBoundType;
1815
1978
  return newInstance;
1816
1979
  }
1817
1980
  TypeVarType.cloneAsSpecializedSelf = cloneAsSpecializedSelf;
1818
1981
  function cloneAsInScopePlaceholder(type, usageOffset) {
1819
- if (type.isInScopePlaceholder) {
1982
+ if (type.priv.isInScopePlaceholder) {
1820
1983
  return type;
1821
1984
  }
1822
1985
  // If the caller specified a usage offset, append it to the TypeVar
1823
1986
  // internal name. This allows us to distinguish it from other uses
1824
1987
  // of the same TypeVar. For example nested calls to a generic
1825
1988
  // function like `foo(foo(1))`.
1826
- let newNameWithScope = type.nameWithScope;
1989
+ let newNameWithScope = type.priv.nameWithScope;
1827
1990
  if (usageOffset) {
1828
- newNameWithScope = `${type.nameWithScope}-${usageOffset}`;
1991
+ newNameWithScope = `${type.priv.nameWithScope}-${usageOffset}`;
1829
1992
  }
1830
1993
  const newInstance = TypeBase.cloneType(type);
1831
- newInstance.isInScopePlaceholder = true;
1832
- newInstance.scopeId = exports.InScopePlaceholderScopeId;
1833
- newInstance.nameWithScope = newNameWithScope;
1994
+ newInstance.priv.isInScopePlaceholder = true;
1995
+ newInstance.priv.scopeId = exports.InScopePlaceholderScopeId;
1996
+ newInstance.priv.nameWithScope = newNameWithScope;
1834
1997
  return newInstance;
1835
1998
  }
1836
1999
  TypeVarType.cloneAsInScopePlaceholder = cloneAsInScopePlaceholder;
@@ -1838,41 +2001,71 @@ var TypeVarType;
1838
2001
  return `${name}.${scopeId}`;
1839
2002
  }
1840
2003
  TypeVarType.makeNameWithScope = makeNameWithScope;
2004
+ function makeInternalScopeId(scopeId) {
2005
+ if (!scopeId) {
2006
+ return undefined;
2007
+ }
2008
+ return `${scopeId}*`;
2009
+ }
2010
+ TypeVarType.makeInternalScopeId = makeInternalScopeId;
2011
+ function cloneWithInternalScopeId(type) {
2012
+ if (type.priv.scopeId === undefined || type.priv.externalTypeVar) {
2013
+ return type;
2014
+ }
2015
+ const clone = TypeVarType.cloneForScopeId(type, TypeVarType.makeInternalScopeId(type.priv.scopeId), type.priv.scopeName, type.priv.scopeType);
2016
+ clone.priv.externalTypeVar = type;
2017
+ return clone;
2018
+ }
2019
+ TypeVarType.cloneWithInternalScopeId = cloneWithInternalScopeId;
2020
+ function hasInternalScopeId(type) {
2021
+ return !!type.priv.externalTypeVar;
2022
+ }
2023
+ TypeVarType.hasInternalScopeId = hasInternalScopeId;
1841
2024
  function create(name, isParamSpec, typeFlags) {
1842
2025
  const newTypeVarType = {
1843
2026
  category: 9 /* TypeCategory.TypeVar */,
1844
- details: {
2027
+ flags: typeFlags,
2028
+ props: undefined,
2029
+ cached: undefined,
2030
+ shared: {
1845
2031
  name,
1846
2032
  constraints: [],
1847
- declaredVariance: 2 /* Variance.Invariant */,
2033
+ boundType: undefined,
2034
+ isDefaultExplicit: false,
2035
+ defaultType: UnknownType.create(),
1848
2036
  isParamSpec,
1849
2037
  isVariadic: false,
2038
+ declaredVariance: 2 /* Variance.Invariant */,
1850
2039
  isSynthesized: false,
1851
- defaultType: UnknownType.create(),
2040
+ isSynthesizedSelf: false,
2041
+ synthesizedIndex: undefined,
2042
+ isExemptFromBoundCheck: false,
2043
+ isTypeParamSyntax: false,
2044
+ recursiveAlias: undefined,
1852
2045
  },
1853
- flags: typeFlags,
2046
+ priv: {},
1854
2047
  };
1855
2048
  return newTypeVarType;
1856
2049
  }
1857
- function addConstraint(typeVarType, constraintType) {
1858
- typeVarType.details.constraints.push(constraintType);
2050
+ function addConstraint(type, constraintType) {
2051
+ type.shared.constraints.push(constraintType);
1859
2052
  }
1860
2053
  TypeVarType.addConstraint = addConstraint;
1861
2054
  function getNameWithScope(typeVarType) {
1862
2055
  // If there is no name with scope, fall back on the (unscoped) name.
1863
- return typeVarType.nameWithScope || typeVarType.details.name;
2056
+ return typeVarType.priv.nameWithScope || typeVarType.shared.name;
1864
2057
  }
1865
2058
  TypeVarType.getNameWithScope = getNameWithScope;
1866
- function getReadableName(typeVarType) {
1867
- if (typeVarType.scopeName) {
1868
- return `${typeVarType.details.name}@${typeVarType.scopeName}`;
2059
+ function getReadableName(type) {
2060
+ if (type.priv.scopeName) {
2061
+ return `${type.shared.name}@${type.priv.scopeName}`;
1869
2062
  }
1870
- return typeVarType.details.name;
2063
+ return type.shared.name;
1871
2064
  }
1872
2065
  TypeVarType.getReadableName = getReadableName;
1873
2066
  function getVariance(type) {
1874
2067
  var _a;
1875
- const variance = (_a = type.computedVariance) !== null && _a !== void 0 ? _a : type.details.declaredVariance;
2068
+ const variance = (_a = type.priv.computedVariance) !== null && _a !== void 0 ? _a : type.shared.declaredVariance;
1876
2069
  // By this point, the variance should have been inferred.
1877
2070
  (0, debug_1.assert)(variance !== 0 /* Variance.Auto */, 'Expected variance to be inferred');
1878
2071
  // If we're in the process of computing variance, it will still be
@@ -1886,7 +2079,7 @@ var TypeVarType;
1886
2079
  // Indicates whether the specified type is a recursive type alias
1887
2080
  // placeholder that has not yet been resolved.
1888
2081
  function isTypeAliasPlaceholder(type) {
1889
- return !!type.details.recursiveTypeAliasName && !type.details.boundType;
2082
+ return !!type.shared.recursiveAlias && !type.shared.boundType;
1890
2083
  }
1891
2084
  TypeVarType.isTypeAliasPlaceholder = isTypeAliasPlaceholder;
1892
2085
  })(TypeVarType || (exports.TypeVarType = TypeVarType = {}));
@@ -1907,7 +2100,7 @@ function isAnyOrUnknown(type) {
1907
2100
  return true;
1908
2101
  }
1909
2102
  if (isUnion(type)) {
1910
- return type.subtypes.find((subtype) => !isAnyOrUnknown(subtype)) === undefined;
2103
+ return type.priv.subtypes.find((subtype) => !isAnyOrUnknown(subtype)) === undefined;
1911
2104
  }
1912
2105
  return false;
1913
2106
  }
@@ -1925,7 +2118,7 @@ function isPossiblyUnbound(type) {
1925
2118
  return true;
1926
2119
  }
1927
2120
  if (isUnion(type)) {
1928
- return type.subtypes.find((subtype) => isPossiblyUnbound(subtype)) !== undefined;
2121
+ return type.priv.subtypes.find((subtype) => isPossiblyUnbound(subtype)) !== undefined;
1929
2122
  }
1930
2123
  return false;
1931
2124
  }
@@ -1951,18 +2144,18 @@ function isTypeVar(type) {
1951
2144
  }
1952
2145
  exports.isTypeVar = isTypeVar;
1953
2146
  function isVariadicTypeVar(type) {
1954
- return type.category === 9 /* TypeCategory.TypeVar */ && type.details.isVariadic;
2147
+ return type.category === 9 /* TypeCategory.TypeVar */ && type.shared.isVariadic;
1955
2148
  }
1956
2149
  exports.isVariadicTypeVar = isVariadicTypeVar;
1957
2150
  function isUnpackedVariadicTypeVar(type) {
1958
2151
  return (type.category === 9 /* TypeCategory.TypeVar */ &&
1959
- type.details.isVariadic &&
1960
- !!type.isVariadicUnpacked &&
1961
- !type.isVariadicInUnion);
2152
+ type.shared.isVariadic &&
2153
+ !!type.priv.isVariadicUnpacked &&
2154
+ !type.priv.isVariadicInUnion);
1962
2155
  }
1963
2156
  exports.isUnpackedVariadicTypeVar = isUnpackedVariadicTypeVar;
1964
2157
  function isUnpackedClass(type) {
1965
- if (!isClass(type) || !type.isUnpacked) {
2158
+ if (!isClass(type) || !type.priv.isUnpacked) {
1966
2159
  return false;
1967
2160
  }
1968
2161
  return true;
@@ -1973,7 +2166,7 @@ function isUnpacked(type) {
1973
2166
  }
1974
2167
  exports.isUnpacked = isUnpacked;
1975
2168
  function isParamSpec(type) {
1976
- return type.category === 9 /* TypeCategory.TypeVar */ && type.details.isParamSpec;
2169
+ return type.category === 9 /* TypeCategory.TypeVar */ && type.shared.isParamSpec;
1977
2170
  }
1978
2171
  exports.isParamSpec = isParamSpec;
1979
2172
  function isFunction(type) {
@@ -1985,14 +2178,15 @@ function isOverloadedFunction(type) {
1985
2178
  }
1986
2179
  exports.isOverloadedFunction = isOverloadedFunction;
1987
2180
  function getTypeAliasInfo(type) {
1988
- if (type.typeAliasInfo) {
1989
- return type.typeAliasInfo;
2181
+ var _a, _b;
2182
+ if ((_a = type.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo) {
2183
+ return type.props.typeAliasInfo;
1990
2184
  }
1991
2185
  if (isTypeVar(type) &&
1992
- type.details.recursiveTypeAliasName &&
1993
- type.details.boundType &&
1994
- type.details.boundType.typeAliasInfo) {
1995
- return type.details.boundType.typeAliasInfo;
2186
+ type.shared.recursiveAlias &&
2187
+ type.shared.boundType &&
2188
+ ((_b = type.shared.boundType.props) === null || _b === void 0 ? void 0 : _b.typeAliasInfo)) {
2189
+ return type.shared.boundType.props.typeAliasInfo;
1996
2190
  }
1997
2191
  return undefined;
1998
2192
  }
@@ -2001,7 +2195,7 @@ exports.getTypeAliasInfo = getTypeAliasInfo;
2001
2195
  // type arguments for "pseudo-generic" classes (non-generic classes whose init
2002
2196
  // methods are not annotated and are therefore treated as generic) are ignored.
2003
2197
  function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2004
- var _a, _b;
2198
+ var _a, _b, _c, _d, _e, _f;
2005
2199
  if (type1 === type2) {
2006
2200
  return true;
2007
2201
  }
@@ -2017,7 +2211,7 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2017
2211
  return false;
2018
2212
  }
2019
2213
  if (!options.ignoreTypeFlags) {
2020
- if (type1.flags !== type2.flags) {
2214
+ if ((type1.flags & 3 /* TypeFlags.TypeCompatibilityMask */) !== (type2.flags & 3 /* TypeFlags.TypeCompatibilityMask */)) {
2021
2215
  return false;
2022
2216
  }
2023
2217
  }
@@ -2032,14 +2226,14 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2032
2226
  if (!ClassType.isSameGenericClass(type1, classType2, recursionCount)) {
2033
2227
  return false;
2034
2228
  }
2035
- if (!options.ignoreConditions && !TypeCondition.isSame(type1.condition, type2.condition)) {
2229
+ if (!options.ignoreConditions && !TypeCondition.isSame((_a = type1.props) === null || _a === void 0 ? void 0 : _a.condition, (_b = type2.props) === null || _b === void 0 ? void 0 : _b.condition)) {
2036
2230
  return false;
2037
2231
  }
2038
2232
  if (!options.ignorePseudoGeneric || !ClassType.isPseudoGenericClass(type1)) {
2039
2233
  // Make sure the type args match.
2040
- if (type1.tupleTypeArguments && classType2.tupleTypeArguments) {
2041
- const type1TupleTypeArgs = type1.tupleTypeArguments || [];
2042
- const type2TupleTypeArgs = classType2.tupleTypeArguments || [];
2234
+ if (type1.priv.tupleTypeArguments && classType2.priv.tupleTypeArguments) {
2235
+ const type1TupleTypeArgs = type1.priv.tupleTypeArguments || [];
2236
+ const type2TupleTypeArgs = classType2.priv.tupleTypeArguments || [];
2043
2237
  if (type1TupleTypeArgs.length !== type2TupleTypeArgs.length) {
2044
2238
  return false;
2045
2239
  }
@@ -2053,8 +2247,8 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2053
2247
  }
2054
2248
  }
2055
2249
  else {
2056
- const type1TypeArgs = type1.typeArguments || [];
2057
- const type2TypeArgs = classType2.typeArguments || [];
2250
+ const type1TypeArgs = type1.priv.typeArguments || [];
2251
+ const type2TypeArgs = classType2.priv.typeArguments || [];
2058
2252
  const typeArgCount = Math.max(type1TypeArgs.length, type2TypeArgs.length);
2059
2253
  for (let i = 0; i < typeArgCount; i++) {
2060
2254
  // Assume that missing type args are "Unknown".
@@ -2069,7 +2263,7 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2069
2263
  if (!ClassType.isLiteralValueSame(type1, classType2)) {
2070
2264
  return false;
2071
2265
  }
2072
- if (!type1.isTypedDictPartial !== !classType2.isTypedDictPartial) {
2266
+ if (!type1.priv.isTypedDictPartial !== !classType2.priv.isTypedDictPartial) {
2073
2267
  return false;
2074
2268
  }
2075
2269
  if (!options.ignoreTypedDictNarrowEntries && !ClassType.isTypedDictNarrowedEntriesSame(type1, classType2)) {
@@ -2080,8 +2274,8 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2080
2274
  case 4 /* TypeCategory.Function */: {
2081
2275
  // Make sure the parameter counts match.
2082
2276
  const functionType2 = type2;
2083
- const params1 = type1.details.parameters;
2084
- const params2 = functionType2.details.parameters;
2277
+ const params1 = type1.shared.parameters;
2278
+ const params2 = functionType2.shared.parameters;
2085
2279
  if (params1.length !== params2.length) {
2086
2280
  return false;
2087
2281
  }
@@ -2121,19 +2315,19 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2121
2315
  }
2122
2316
  }
2123
2317
  // Make sure the return types match.
2124
- let return1Type = type1.details.declaredReturnType;
2125
- if (type1.specializedTypes && type1.specializedTypes.returnType) {
2126
- return1Type = type1.specializedTypes.returnType;
2318
+ let return1Type = type1.shared.declaredReturnType;
2319
+ if (type1.priv.specializedTypes && type1.priv.specializedTypes.returnType) {
2320
+ return1Type = type1.priv.specializedTypes.returnType;
2127
2321
  }
2128
- if (!return1Type && type1.inferredReturnType) {
2129
- return1Type = type1.inferredReturnType;
2322
+ if (!return1Type && type1.priv.inferredReturnType) {
2323
+ return1Type = type1.priv.inferredReturnType;
2130
2324
  }
2131
- let return2Type = functionType2.details.declaredReturnType;
2132
- if (functionType2.specializedTypes && functionType2.specializedTypes.returnType) {
2133
- return2Type = functionType2.specializedTypes.returnType;
2325
+ let return2Type = functionType2.shared.declaredReturnType;
2326
+ if (functionType2.priv.specializedTypes && functionType2.priv.specializedTypes.returnType) {
2327
+ return2Type = functionType2.priv.specializedTypes.returnType;
2134
2328
  }
2135
- if (!return2Type && functionType2.inferredReturnType) {
2136
- return2Type = functionType2.inferredReturnType;
2329
+ if (!return2Type && functionType2.priv.inferredReturnType) {
2330
+ return2Type = functionType2.priv.inferredReturnType;
2137
2331
  }
2138
2332
  if (return1Type || return2Type) {
2139
2333
  if (!return1Type ||
@@ -2147,13 +2341,13 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2147
2341
  case 5 /* TypeCategory.OverloadedFunction */: {
2148
2342
  // Make sure the overload counts match.
2149
2343
  const functionType2 = type2;
2150
- if (type1.overloads.length !== functionType2.overloads.length) {
2344
+ if (type1.priv.overloads.length !== functionType2.priv.overloads.length) {
2151
2345
  return false;
2152
2346
  }
2153
2347
  // We assume here that overloaded functions always appear
2154
2348
  // in the same order from one analysis pass to another.
2155
- for (let i = 0; i < type1.overloads.length; i++) {
2156
- if (!isTypeSame(type1.overloads[i], functionType2.overloads[i], options, recursionCount)) {
2349
+ for (let i = 0; i < type1.priv.overloads.length; i++) {
2350
+ if (!isTypeSame(type1.priv.overloads[i], functionType2.priv.overloads[i], options, recursionCount)) {
2157
2351
  return false;
2158
2352
  }
2159
2353
  }
@@ -2161,8 +2355,8 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2161
2355
  }
2162
2356
  case 8 /* TypeCategory.Union */: {
2163
2357
  const unionType2 = type2;
2164
- const subtypes1 = type1.subtypes;
2165
- const subtypes2 = unionType2.subtypes;
2358
+ const subtypes1 = type1.priv.subtypes;
2359
+ const subtypes2 = unionType2.priv.subtypes;
2166
2360
  if (subtypes1.length !== subtypes2.length) {
2167
2361
  return false;
2168
2362
  }
@@ -2173,14 +2367,14 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2173
2367
  }
2174
2368
  case 9 /* TypeCategory.TypeVar */: {
2175
2369
  const type2TypeVar = type2;
2176
- if (type1.scopeId !== type2TypeVar.scopeId) {
2370
+ if (type1.priv.scopeId !== type2TypeVar.priv.scopeId) {
2177
2371
  return false;
2178
2372
  }
2179
2373
  // Handle the case where this is a generic recursive type alias. Make
2180
2374
  // sure that the type argument types match.
2181
- if (type1.details.recursiveTypeParameters && type2TypeVar.details.recursiveTypeParameters) {
2182
- const type1TypeArgs = ((_a = type1 === null || type1 === void 0 ? void 0 : type1.typeAliasInfo) === null || _a === void 0 ? void 0 : _a.typeArguments) || [];
2183
- const type2TypeArgs = ((_b = type2 === null || type2 === void 0 ? void 0 : type2.typeAliasInfo) === null || _b === void 0 ? void 0 : _b.typeArguments) || [];
2375
+ if (type1.shared.recursiveAlias && type2TypeVar.shared.recursiveAlias) {
2376
+ const type1TypeArgs = ((_d = (_c = type1 === null || type1 === void 0 ? void 0 : type1.props) === null || _c === void 0 ? void 0 : _c.typeAliasInfo) === null || _d === void 0 ? void 0 : _d.typeArguments) || [];
2377
+ const type2TypeArgs = ((_f = (_e = type2 === null || type2 === void 0 ? void 0 : type2.props) === null || _e === void 0 ? void 0 : _e.typeAliasInfo) === null || _f === void 0 ? void 0 : _f.typeArguments) || [];
2184
2378
  const typeArgCount = Math.max(type1TypeArgs.length, type2TypeArgs.length);
2185
2379
  for (let i = 0; i < typeArgCount; i++) {
2186
2380
  // Assume that missing type args are "Any".
@@ -2191,22 +2385,22 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2191
2385
  }
2192
2386
  }
2193
2387
  }
2194
- if (!type1.isVariadicInUnion !== !type2TypeVar.isVariadicInUnion) {
2388
+ if (!type1.priv.isVariadicInUnion !== !type2TypeVar.priv.isVariadicInUnion) {
2195
2389
  return false;
2196
2390
  }
2197
- if (type1.details === type2TypeVar.details) {
2391
+ if (type1.shared === type2TypeVar.shared) {
2198
2392
  return true;
2199
2393
  }
2200
- if (type1.details.name !== type2TypeVar.details.name ||
2201
- type1.details.isParamSpec !== type2TypeVar.details.isParamSpec ||
2202
- type1.details.isVariadic !== type2TypeVar.details.isVariadic ||
2203
- type1.details.isSynthesized !== type2TypeVar.details.isSynthesized ||
2204
- type1.details.declaredVariance !== type2TypeVar.details.declaredVariance ||
2205
- type1.scopeId !== type2TypeVar.scopeId) {
2394
+ if (type1.shared.name !== type2TypeVar.shared.name ||
2395
+ type1.shared.isParamSpec !== type2TypeVar.shared.isParamSpec ||
2396
+ type1.shared.isVariadic !== type2TypeVar.shared.isVariadic ||
2397
+ type1.shared.isSynthesized !== type2TypeVar.shared.isSynthesized ||
2398
+ type1.shared.declaredVariance !== type2TypeVar.shared.declaredVariance ||
2399
+ type1.priv.scopeId !== type2TypeVar.priv.scopeId) {
2206
2400
  return false;
2207
2401
  }
2208
- const boundType1 = type1.details.boundType;
2209
- const boundType2 = type2TypeVar.details.boundType;
2402
+ const boundType1 = type1.shared.boundType;
2403
+ const boundType2 = type2TypeVar.shared.boundType;
2210
2404
  if (boundType1) {
2211
2405
  if (!boundType2 ||
2212
2406
  !isTypeSame(boundType1, boundType2, { ...options, ignoreTypeFlags: false }, recursionCount)) {
@@ -2218,8 +2412,8 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2218
2412
  return false;
2219
2413
  }
2220
2414
  }
2221
- const constraints1 = type1.details.constraints;
2222
- const constraints2 = type2TypeVar.details.constraints;
2415
+ const constraints1 = type1.shared.constraints;
2416
+ const constraints2 = type2TypeVar.shared.constraints;
2223
2417
  if (constraints1.length !== constraints2.length) {
2224
2418
  return false;
2225
2419
  }
@@ -2234,19 +2428,19 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2234
2428
  const type2Module = type2;
2235
2429
  // Module types are the same if they share the same
2236
2430
  // module symbol table.
2237
- if (type1.fields === type2Module.fields) {
2431
+ if (type1.priv.fields === type2Module.priv.fields) {
2238
2432
  return true;
2239
2433
  }
2240
2434
  // If both symbol tables are empty, we can also assume
2241
2435
  // they're equal.
2242
- if (type1.fields.size === 0 && type2Module.fields.size === 0) {
2436
+ if (type1.priv.fields.size === 0 && type2Module.priv.fields.size === 0) {
2243
2437
  return true;
2244
2438
  }
2245
2439
  return false;
2246
2440
  }
2247
2441
  case 1 /* TypeCategory.Unknown */: {
2248
2442
  const type2Unknown = type2;
2249
- return type1.isIncomplete === type2Unknown.isIncomplete;
2443
+ return type1.priv.isIncomplete === type2Unknown.priv.isIncomplete;
2250
2444
  }
2251
2445
  }
2252
2446
  return true;
@@ -2272,8 +2466,8 @@ function removeUnbound(type) {
2272
2466
  exports.removeUnbound = removeUnbound;
2273
2467
  function removeFromUnion(type, removeFilter) {
2274
2468
  if (isUnion(type)) {
2275
- const remainingTypes = type.subtypes.filter((t) => !removeFilter(t));
2276
- if (remainingTypes.length < type.subtypes.length) {
2469
+ const remainingTypes = type.priv.subtypes.filter((t) => !removeFilter(t));
2470
+ if (remainingTypes.length < type.priv.subtypes.length) {
2277
2471
  const newType = combineTypes(remainingTypes);
2278
2472
  if (isUnion(newType)) {
2279
2473
  UnionType.addTypeAliasSource(newType, type);
@@ -2286,7 +2480,7 @@ function removeFromUnion(type, removeFilter) {
2286
2480
  exports.removeFromUnion = removeFromUnion;
2287
2481
  function findSubtype(type, filter) {
2288
2482
  if (isUnion(type)) {
2289
- return type.subtypes.find((subtype) => {
2483
+ return type.priv.subtypes.find((subtype) => {
2290
2484
  return filter(subtype);
2291
2485
  });
2292
2486
  }
@@ -2297,12 +2491,13 @@ exports.findSubtype = findSubtype;
2297
2491
  // the same, only one is returned. If they differ, they
2298
2492
  // are combined into a UnionType. NeverTypes are filtered out.
2299
2493
  // If no types remain in the end, a NeverType is returned.
2300
- function combineTypes(subtypes, maxSubtypeCount) {
2494
+ function combineTypes(subtypes, options) {
2495
+ var _a;
2301
2496
  // Filter out any "Never" and "NoReturn" types.
2302
2497
  let sawNoReturn = false;
2303
2498
  if (subtypes.some((subtype) => subtype.category === 3 /* TypeCategory.Never */))
2304
2499
  subtypes = subtypes.filter((subtype) => {
2305
- if (subtype.category === 3 /* TypeCategory.Never */ && subtype.isNoReturn) {
2500
+ if (subtype.category === 3 /* TypeCategory.Never */ && subtype.priv.isNoReturn) {
2306
2501
  sawNoReturn = true;
2307
2502
  }
2308
2503
  return subtype.category !== 3 /* TypeCategory.Never */;
@@ -2333,12 +2528,12 @@ function combineTypes(subtypes, maxSubtypeCount) {
2333
2528
  if (!expandedTypes) {
2334
2529
  expandedTypes = subtypes.slice(0, i);
2335
2530
  }
2336
- expandedTypes = expandedTypes.concat(subtype.subtypes);
2337
- if (subtype.typeAliasInfo) {
2531
+ expandedTypes = expandedTypes.concat(subtype.priv.subtypes);
2532
+ if ((_a = subtype.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo) {
2338
2533
  typeAliasSources.add(subtype);
2339
2534
  }
2340
- else if (subtype.typeAliasSources) {
2341
- subtype.typeAliasSources.forEach((subtype) => {
2535
+ else if (subtype.priv.typeAliasSources) {
2536
+ subtype.priv.typeAliasSources.forEach((subtype) => {
2342
2537
  typeAliasSources.add(subtype);
2343
2538
  });
2344
2539
  }
@@ -2350,16 +2545,16 @@ function combineTypes(subtypes, maxSubtypeCount) {
2350
2545
  expandedTypes = expandedTypes !== null && expandedTypes !== void 0 ? expandedTypes : subtypes;
2351
2546
  // Sort all of the literal and empty types to the end.
2352
2547
  expandedTypes = expandedTypes.sort((type1, type2) => {
2353
- if (isClass(type1) && type1.literalValue !== undefined) {
2548
+ if (isClass(type1) && type1.priv.literalValue !== undefined) {
2354
2549
  return 1;
2355
2550
  }
2356
- if (isClass(type2) && type2.literalValue !== undefined) {
2551
+ if (isClass(type2) && type2.priv.literalValue !== undefined) {
2357
2552
  return -1;
2358
2553
  }
2359
- if (isClassInstance(type1) && type1.isEmptyContainer) {
2554
+ if (isClassInstance(type1) && type1.priv.isEmptyContainer) {
2360
2555
  return 1;
2361
2556
  }
2362
- else if (isClassInstance(type2) && type2.isEmptyContainer) {
2557
+ else if (isClassInstance(type2) && type2.priv.isEmptyContainer) {
2363
2558
  return -1;
2364
2559
  }
2365
2560
  return 0;
@@ -2371,7 +2566,7 @@ function combineTypes(subtypes, maxSubtypeCount) {
2371
2566
  }
2372
2567
  const newUnionType = UnionType.create();
2373
2568
  if (typeAliasSources.size > 0) {
2374
- newUnionType.typeAliasSources = typeAliasSources;
2569
+ newUnionType.priv.typeAliasSources = typeAliasSources;
2375
2570
  }
2376
2571
  let hitMaxSubtypeCount = false;
2377
2572
  expandedTypes.forEach((subtype, index) => {
@@ -2379,8 +2574,8 @@ function combineTypes(subtypes, maxSubtypeCount) {
2379
2574
  UnionType.addType(newUnionType, subtype);
2380
2575
  }
2381
2576
  else {
2382
- if (maxSubtypeCount === undefined || newUnionType.subtypes.length < maxSubtypeCount) {
2383
- _addTypeIfUnique(newUnionType, subtype);
2577
+ if ((options === null || options === void 0 ? void 0 : options.maxSubtypeCount) === undefined || newUnionType.priv.subtypes.length < options.maxSubtypeCount) {
2578
+ _addTypeIfUnique(newUnionType, subtype, !(options === null || options === void 0 ? void 0 : options.skipElideRedundantLiterals));
2384
2579
  }
2385
2580
  else {
2386
2581
  hitMaxSubtypeCount = true;
@@ -2391,8 +2586,8 @@ function combineTypes(subtypes, maxSubtypeCount) {
2391
2586
  return AnyType.create();
2392
2587
  }
2393
2588
  // If only one type remains, convert it from a union to a simple type.
2394
- if (newUnionType.subtypes.length === 1) {
2395
- return newUnionType.subtypes[0];
2589
+ if (newUnionType.priv.subtypes.length === 1) {
2590
+ return newUnionType.priv.subtypes[0];
2396
2591
  }
2397
2592
  return newUnionType;
2398
2593
  }
@@ -2405,12 +2600,12 @@ function isSameWithoutLiteralValue(destType, srcType) {
2405
2600
  if (isTypeSame(destType, srcType)) {
2406
2601
  return true;
2407
2602
  }
2408
- if (isInstantiableClass(srcType) && srcType.literalValue !== undefined) {
2603
+ if (isInstantiableClass(srcType) && srcType.priv.literalValue !== undefined) {
2409
2604
  // Strip the literal.
2410
2605
  srcType = ClassType.cloneWithLiteral(srcType, /* value */ undefined);
2411
2606
  return isTypeSame(destType, srcType);
2412
2607
  }
2413
- if (isClassInstance(srcType) && srcType.literalValue !== undefined) {
2608
+ if (isClassInstance(srcType) && srcType.priv.literalValue !== undefined) {
2414
2609
  // Strip the literal.
2415
2610
  srcType = ClassType.cloneWithLiteral(srcType, /* value */ undefined);
2416
2611
  return isTypeSame(destType, srcType, { ignoreConditions: true });
@@ -2418,32 +2613,35 @@ function isSameWithoutLiteralValue(destType, srcType) {
2418
2613
  return false;
2419
2614
  }
2420
2615
  exports.isSameWithoutLiteralValue = isSameWithoutLiteralValue;
2421
- function _addTypeIfUnique(unionType, typeToAdd) {
2616
+ function _addTypeIfUnique(unionType, typeToAdd, elideRedundantLiterals) {
2617
+ var _a, _b, _c;
2422
2618
  // Handle the addition of a string literal in a special manner to
2423
2619
  // avoid n^2 behavior in unions that contain hundreds of string
2424
2620
  // literal types. Skip this for constrained types.
2425
- if (isClass(typeToAdd) && typeToAdd.condition === undefined) {
2426
- const literalMaps = isClassInstance(typeToAdd) ? unionType.literalInstances : unionType.literalClasses;
2621
+ if (isClass(typeToAdd) && !((_a = typeToAdd.props) === null || _a === void 0 ? void 0 : _a.condition)) {
2622
+ const literalMaps = isClassInstance(typeToAdd)
2623
+ ? unionType.priv.literalInstances
2624
+ : unionType.priv.literalClasses;
2427
2625
  if (ClassType.isBuiltIn(typeToAdd, 'str') &&
2428
- typeToAdd.literalValue !== undefined &&
2626
+ typeToAdd.priv.literalValue !== undefined &&
2429
2627
  literalMaps.literalStrMap !== undefined) {
2430
- if (!literalMaps.literalStrMap.has(typeToAdd.literalValue)) {
2628
+ if (!literalMaps.literalStrMap.has(typeToAdd.priv.literalValue)) {
2431
2629
  UnionType.addType(unionType, typeToAdd);
2432
2630
  }
2433
2631
  return;
2434
2632
  }
2435
2633
  else if (ClassType.isBuiltIn(typeToAdd, 'int') &&
2436
- typeToAdd.literalValue !== undefined &&
2634
+ typeToAdd.priv.literalValue !== undefined &&
2437
2635
  literalMaps.literalIntMap !== undefined) {
2438
- if (!literalMaps.literalIntMap.has(typeToAdd.literalValue)) {
2636
+ if (!literalMaps.literalIntMap.has(typeToAdd.priv.literalValue)) {
2439
2637
  UnionType.addType(unionType, typeToAdd);
2440
2638
  }
2441
2639
  return;
2442
2640
  }
2443
2641
  else if (ClassType.isEnumClass(typeToAdd) &&
2444
- typeToAdd.literalValue !== undefined &&
2642
+ typeToAdd.priv.literalValue !== undefined &&
2445
2643
  literalMaps.literalEnumMap !== undefined) {
2446
- const enumLiteral = typeToAdd.literalValue;
2644
+ const enumLiteral = typeToAdd.priv.literalValue;
2447
2645
  if (!literalMaps.literalEnumMap.has(enumLiteral.getName())) {
2448
2646
  UnionType.addType(unionType, typeToAdd);
2449
2647
  }
@@ -2451,8 +2649,8 @@ function _addTypeIfUnique(unionType, typeToAdd) {
2451
2649
  }
2452
2650
  }
2453
2651
  const isPseudoGeneric = isClass(typeToAdd) && ClassType.isPseudoGenericClass(typeToAdd);
2454
- for (let i = 0; i < unionType.subtypes.length; i++) {
2455
- const type = unionType.subtypes[i];
2652
+ for (let i = 0; i < unionType.priv.subtypes.length; i++) {
2653
+ const type = unionType.priv.subtypes[i];
2456
2654
  // Does this type already exist in the types array?
2457
2655
  if (isTypeSame(type, typeToAdd)) {
2458
2656
  return;
@@ -2465,27 +2663,28 @@ function _addTypeIfUnique(unionType, typeToAdd) {
2465
2663
  // parameterized with its own class) ad infinitum.
2466
2664
  if (isPseudoGeneric) {
2467
2665
  if (isTypeSame(type, typeToAdd, { ignorePseudoGeneric: true })) {
2468
- unionType.subtypes[i] = ClassType.cloneForSpecialization(typeToAdd, typeToAdd.details.typeParameters.map(() => UnknownType.create()),
2666
+ unionType.priv.subtypes[i] = ClassType.cloneForSpecialization(typeToAdd, typeToAdd.shared.typeParameters.map(() => UnknownType.create()),
2469
2667
  /* isTypeArgumentExplicit */ true);
2470
2668
  return;
2471
2669
  }
2472
2670
  }
2473
- // If the typeToAdd is a literal value and there's already
2474
- // a non-literal type that matches, don't add the literal value.
2475
2671
  if (isClassInstance(type) && isClassInstance(typeToAdd)) {
2476
- if (isSameWithoutLiteralValue(type, typeToAdd)) {
2477
- if (type.literalValue === undefined) {
2672
+ // If the typeToAdd is a literal value and there's already
2673
+ // a non-literal type that matches, don't add the literal value.
2674
+ if (elideRedundantLiterals && isSameWithoutLiteralValue(type, typeToAdd)) {
2675
+ if (type.priv.literalValue === undefined) {
2478
2676
  return;
2479
2677
  }
2480
2678
  }
2481
2679
  // If we're adding Literal[False] or Literal[True] to its
2482
2680
  // opposite, combine them into a non-literal 'bool' type.
2483
2681
  if (ClassType.isBuiltIn(type, 'bool') &&
2484
- !type.condition &&
2682
+ !((_b = type.props) === null || _b === void 0 ? void 0 : _b.condition) &&
2485
2683
  ClassType.isBuiltIn(typeToAdd, 'bool') &&
2486
- !typeToAdd.condition) {
2487
- if (typeToAdd.literalValue !== undefined && !typeToAdd.literalValue === type.literalValue) {
2488
- unionType.subtypes[i] = ClassType.cloneWithLiteral(type, /* value */ undefined);
2684
+ !((_c = typeToAdd.props) === null || _c === void 0 ? void 0 : _c.condition)) {
2685
+ if (typeToAdd.priv.literalValue !== undefined &&
2686
+ !typeToAdd.priv.literalValue === type.priv.literalValue) {
2687
+ unionType.priv.subtypes[i] = ClassType.cloneWithLiteral(type, /* value */ undefined);
2489
2688
  return;
2490
2689
  }
2491
2690
  }
@@ -2493,12 +2692,12 @@ function _addTypeIfUnique(unionType, typeToAdd) {
2493
2692
  // existing type, see if one of them is a proper subset of the other.
2494
2693
  if (ClassType.isTypedDictClass(type) && ClassType.isSameGenericClass(type, typeToAdd)) {
2495
2694
  // Do not proceed if the TypedDicts are generic and have different type arguments.
2496
- if (!type.typeArguments && !typeToAdd.typeArguments) {
2695
+ if (!type.priv.typeArguments && !typeToAdd.priv.typeArguments) {
2497
2696
  if (ClassType.isTypedDictNarrower(typeToAdd, type)) {
2498
2697
  return;
2499
2698
  }
2500
2699
  else if (ClassType.isTypedDictNarrower(type, typeToAdd)) {
2501
- unionType.subtypes[i] = typeToAdd;
2700
+ unionType.priv.subtypes[i] = typeToAdd;
2502
2701
  return;
2503
2702
  }
2504
2703
  }
@@ -2506,7 +2705,7 @@ function _addTypeIfUnique(unionType, typeToAdd) {
2506
2705
  }
2507
2706
  // If the typeToAdd is an empty container and there's already
2508
2707
  // non-empty container of the same type, don't add the empty container.
2509
- if (isClassInstance(typeToAdd) && typeToAdd.isEmptyContainer) {
2708
+ if (isClassInstance(typeToAdd) && typeToAdd.priv.isEmptyContainer) {
2510
2709
  if (isClassInstance(type) && ClassType.isSameGenericClass(type, typeToAdd)) {
2511
2710
  return;
2512
2711
  }