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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) 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 +649 -634
  6. package/dist/analyzer/checker.js.map +1 -1
  7. package/dist/analyzer/codeFlowEngine.d.ts +5 -3
  8. package/dist/analyzer/codeFlowEngine.js +87 -101
  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 +68 -64
  13. package/dist/analyzer/constraintSolver.js.map +1 -1
  14. package/dist/analyzer/constructorTransform.js +22 -22
  15. package/dist/analyzer/constructorTransform.js.map +1 -1
  16. package/dist/analyzer/constructors.js +51 -48
  17. package/dist/analyzer/constructors.js.map +1 -1
  18. package/dist/analyzer/dataClasses.js +109 -175
  19. package/dist/analyzer/dataClasses.js.map +1 -1
  20. package/dist/analyzer/declarationUtils.js +14 -15
  21. package/dist/analyzer/declarationUtils.js.map +1 -1
  22. package/dist/analyzer/decorators.js +77 -77
  23. package/dist/analyzer/decorators.js.map +1 -1
  24. package/dist/analyzer/enums.js +70 -56
  25. package/dist/analyzer/enums.js.map +1 -1
  26. package/dist/analyzer/functionTransform.js +8 -18
  27. package/dist/analyzer/functionTransform.js.map +1 -1
  28. package/dist/analyzer/importResolver.d.ts +2 -1
  29. package/dist/analyzer/importResolver.js +40 -29
  30. package/dist/analyzer/importResolver.js.map +1 -1
  31. package/dist/analyzer/importStatementUtils.js +27 -27
  32. package/dist/analyzer/importStatementUtils.js.map +1 -1
  33. package/dist/analyzer/namedTuples.js +33 -59
  34. package/dist/analyzer/namedTuples.js.map +1 -1
  35. package/dist/analyzer/operations.js +66 -66
  36. package/dist/analyzer/operations.js.map +1 -1
  37. package/dist/analyzer/packageTypeVerifier.js +66 -62
  38. package/dist/analyzer/packageTypeVerifier.js.map +1 -1
  39. package/dist/analyzer/parameterUtils.d.ts +4 -4
  40. package/dist/analyzer/parameterUtils.js +28 -46
  41. package/dist/analyzer/parameterUtils.js.map +1 -1
  42. package/dist/analyzer/parseTreeUtils.js +268 -269
  43. package/dist/analyzer/parseTreeUtils.js.map +1 -1
  44. package/dist/analyzer/parseTreeWalker.js +76 -76
  45. package/dist/analyzer/parseTreeWalker.js.map +1 -1
  46. package/dist/analyzer/patternMatching.js +176 -143
  47. package/dist/analyzer/patternMatching.js.map +1 -1
  48. package/dist/analyzer/program.js +1 -1
  49. package/dist/analyzer/program.js.map +1 -1
  50. package/dist/analyzer/properties.js +78 -147
  51. package/dist/analyzer/properties.js.map +1 -1
  52. package/dist/analyzer/protocols.js +21 -21
  53. package/dist/analyzer/protocols.js.map +1 -1
  54. package/dist/analyzer/sourceFile.js +3 -3
  55. package/dist/analyzer/sourceFile.js.map +1 -1
  56. package/dist/analyzer/sourceMapper.js +20 -19
  57. package/dist/analyzer/sourceMapper.js.map +1 -1
  58. package/dist/analyzer/staticExpressions.js +83 -84
  59. package/dist/analyzer/staticExpressions.js.map +1 -1
  60. package/dist/analyzer/testWalker.js +2 -2
  61. package/dist/analyzer/testWalker.js.map +1 -1
  62. package/dist/analyzer/tracePrinter.js +20 -20
  63. package/dist/analyzer/tracePrinter.js.map +1 -1
  64. package/dist/analyzer/typeDocStringUtils.js +25 -25
  65. package/dist/analyzer/typeDocStringUtils.js.map +1 -1
  66. package/dist/analyzer/typeEvaluator.js +1884 -1937
  67. package/dist/analyzer/typeEvaluator.js.map +1 -1
  68. package/dist/analyzer/typeEvaluatorTypes.d.ts +6 -5
  69. package/dist/analyzer/typeEvaluatorTypes.js +4 -1
  70. package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
  71. package/dist/analyzer/typeGuards.js +211 -211
  72. package/dist/analyzer/typeGuards.js.map +1 -1
  73. package/dist/analyzer/typePrinter.js +118 -115
  74. package/dist/analyzer/typePrinter.js.map +1 -1
  75. package/dist/analyzer/typeStubWriter.js +104 -103
  76. package/dist/analyzer/typeStubWriter.js.map +1 -1
  77. package/dist/analyzer/typeUtils.d.ts +14 -3
  78. package/dist/analyzer/typeUtils.js +432 -402
  79. package/dist/analyzer/typeUtils.js.map +1 -1
  80. package/dist/analyzer/typeVarContext.js +8 -8
  81. package/dist/analyzer/typeVarContext.js.map +1 -1
  82. package/dist/analyzer/typeWalker.js +13 -10
  83. package/dist/analyzer/typeWalker.js.map +1 -1
  84. package/dist/analyzer/typedDicts.js +96 -198
  85. package/dist/analyzer/typedDicts.js.map +1 -1
  86. package/dist/analyzer/types.d.ts +144 -102
  87. package/dist/analyzer/types.js +662 -494
  88. package/dist/analyzer/types.js.map +1 -1
  89. package/dist/commands/dumpFileDebugInfoCommand.js +33 -33
  90. package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
  91. package/dist/common/fileSystem.d.ts +1 -0
  92. package/dist/common/fileSystem.js.map +1 -1
  93. package/dist/common/fullAccessHost.js +6 -4
  94. package/dist/common/fullAccessHost.js.map +1 -1
  95. package/dist/common/realFileSystem.d.ts +1 -0
  96. package/dist/common/realFileSystem.js +4 -0
  97. package/dist/common/realFileSystem.js.map +1 -1
  98. package/dist/common/textEditTracker.js +14 -14
  99. package/dist/common/textEditTracker.js.map +1 -1
  100. package/dist/languageService/autoImporter.js +10 -10
  101. package/dist/languageService/autoImporter.js.map +1 -1
  102. package/dist/languageService/callHierarchyProvider.js +23 -23
  103. package/dist/languageService/callHierarchyProvider.js.map +1 -1
  104. package/dist/languageService/completionProvider.js +153 -151
  105. package/dist/languageService/completionProvider.js.map +1 -1
  106. package/dist/languageService/definitionProvider.d.ts +1 -1
  107. package/dist/languageService/definitionProvider.js +3 -1
  108. package/dist/languageService/definitionProvider.js.map +1 -1
  109. package/dist/languageService/documentSymbolCollector.js +19 -19
  110. package/dist/languageService/documentSymbolCollector.js.map +1 -1
  111. package/dist/languageService/hoverProvider.js +25 -24
  112. package/dist/languageService/hoverProvider.js.map +1 -1
  113. package/dist/languageService/importSorter.js +8 -8
  114. package/dist/languageService/importSorter.js.map +1 -1
  115. package/dist/languageService/referencesProvider.js +8 -8
  116. package/dist/languageService/referencesProvider.js.map +1 -1
  117. package/dist/languageService/signatureHelpProvider.d.ts +1 -1
  118. package/dist/languageService/signatureHelpProvider.js +6 -6
  119. package/dist/languageService/signatureHelpProvider.js.map +1 -1
  120. package/dist/languageService/symbolIndexer.js +3 -3
  121. package/dist/languageService/symbolIndexer.js.map +1 -1
  122. package/dist/languageService/tooltipUtils.js +13 -13
  123. package/dist/languageService/tooltipUtils.js.map +1 -1
  124. package/dist/parser/parseNodes.d.ts +468 -401
  125. package/dist/parser/parseNodes.js +626 -355
  126. package/dist/parser/parseNodes.js.map +1 -1
  127. package/dist/parser/parser.d.ts +1 -0
  128. package/dist/parser/parser.js +316 -294
  129. package/dist/parser/parser.js.map +1 -1
  130. package/dist/tests/classDeclaration.test.js +14 -14
  131. package/dist/tests/classDeclaration.test.js.map +1 -1
  132. package/dist/tests/harness/vfs/filesystem.d.ts +3 -2
  133. package/dist/tests/harness/vfs/filesystem.js +6 -2
  134. package/dist/tests/harness/vfs/filesystem.js.map +1 -1
  135. package/dist/tests/importResolver.test.js +4 -3
  136. package/dist/tests/importResolver.test.js.map +1 -1
  137. package/dist/tests/parseTreeUtils.test.js +5 -5
  138. package/dist/tests/parseTreeUtils.test.js.map +1 -1
  139. package/dist/tests/parser.test.js +8 -8
  140. package/dist/tests/parser.test.js.map +1 -1
  141. package/dist/tests/sourceMapperUtils.test.js +7 -7
  142. package/dist/tests/sourceMapperUtils.test.js.map +1 -1
  143. package/dist/tests/typeEvaluator3.test.js +8 -3
  144. package/dist/tests/typeEvaluator3.test.js.map +1 -1
  145. package/dist/tests/typePrinter.test.js +14 -39
  146. package/dist/tests/typePrinter.test.js.map +1 -1
  147. 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,36 @@ 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, trackedSignatures) {
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
+ newFunction.priv.trackedSignatures = trackedSignatures;
1254
+ FunctionType.addHigherOrderTypeVarScopeIds(newFunction, typeParameters.map((t) => t.priv.scopeId));
1137
1255
  return newFunction;
1138
1256
  }
1139
1257
  FunctionType.cloneWithNewTypeVarScopeId = cloneWithNewTypeVarScopeId;
1140
1258
  function cloneWithDocString(type, docString) {
1141
1259
  const newFunction = TypeBase.cloneType(type);
1142
1260
  // Make a shallow clone of the details.
1143
- newFunction.details = { ...type.details };
1144
- newFunction.details.docString = docString;
1261
+ newFunction.shared = { ...type.shared };
1262
+ newFunction.shared.docString = docString;
1145
1263
  return newFunction;
1146
1264
  }
1147
1265
  FunctionType.cloneWithDocString = cloneWithDocString;
1148
1266
  function cloneWithDeprecatedMessage(type, deprecatedMessage) {
1149
1267
  const newFunction = TypeBase.cloneType(type);
1150
1268
  // Make a shallow clone of the details.
1151
- newFunction.details = { ...type.details };
1152
- newFunction.details.deprecatedMessage = deprecatedMessage;
1269
+ newFunction.shared = { ...type.shared };
1270
+ newFunction.shared.deprecatedMessage = deprecatedMessage;
1153
1271
  return newFunction;
1154
1272
  }
1155
1273
  FunctionType.cloneWithDeprecatedMessage = cloneWithDeprecatedMessage;
@@ -1158,12 +1276,12 @@ var FunctionType;
1158
1276
  // *args and **kwargs parameters removed. If stripPositionOnlySeparator is true,
1159
1277
  // a trailing positional-only separator will be removed.
1160
1278
  function cloneRemoveParamSpecArgsKwargs(type, stripPositionOnlySeparator = false) {
1161
- const paramCount = type.details.parameters.length;
1279
+ const paramCount = type.shared.parameters.length;
1162
1280
  if (paramCount < 2) {
1163
1281
  return type;
1164
1282
  }
1165
- const argsParam = type.details.parameters[paramCount - 2];
1166
- const kwargsParam = type.details.parameters[paramCount - 1];
1283
+ const argsParam = type.shared.parameters[paramCount - 2];
1284
+ const kwargsParam = type.shared.parameters[paramCount - 1];
1167
1285
  if (argsParam.category !== 1 /* ParameterCategory.ArgsList */ ||
1168
1286
  kwargsParam.category !== 2 /* ParameterCategory.KwargsDict */) {
1169
1287
  return type;
@@ -1175,8 +1293,8 @@ var FunctionType;
1175
1293
  }
1176
1294
  const newFunction = TypeBase.cloneType(type);
1177
1295
  // Make a shallow clone of the details.
1178
- newFunction.details = { ...type.details };
1179
- const details = newFunction.details;
1296
+ newFunction.shared = { ...type.shared };
1297
+ const details = newFunction.shared;
1180
1298
  let paramsToDrop = 2;
1181
1299
  // If the last remaining parameter is a position-only separator, remove it as well.
1182
1300
  // Always remove it if it's the only remaining parameter.
@@ -1187,16 +1305,16 @@ var FunctionType;
1187
1305
  }
1188
1306
  // Remove the last parameters, which are the *args and **kwargs.
1189
1307
  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);
1308
+ if (type.priv.specializedTypes) {
1309
+ newFunction.priv.specializedTypes = { ...type.priv.specializedTypes };
1310
+ newFunction.priv.specializedTypes.parameterTypes = newFunction.priv.specializedTypes.parameterTypes.slice(0, newFunction.priv.specializedTypes.parameterTypes.length - paramsToDrop);
1311
+ if (newFunction.priv.specializedTypes.parameterDefaultArgs) {
1312
+ newFunction.priv.specializedTypes.parameterDefaultArgs =
1313
+ newFunction.priv.specializedTypes.parameterDefaultArgs.slice(0, newFunction.priv.specializedTypes.parameterDefaultArgs.length - paramsToDrop);
1196
1314
  }
1197
1315
  }
1198
- if (type.inferredReturnType) {
1199
- newFunction.inferredReturnType = type.inferredReturnType;
1316
+ if (type.priv.inferredReturnType) {
1317
+ newFunction.priv.inferredReturnType = type.priv.inferredReturnType;
1200
1318
  }
1201
1319
  return newFunction;
1202
1320
  }
@@ -1204,7 +1322,7 @@ var FunctionType;
1204
1322
  // If the function ends with "*args: P.args, **kwargs: P.kwargs", this function
1205
1323
  // returns P. Otherwise, it returns undefined.
1206
1324
  function getParamSpecFromArgsKwargs(type) {
1207
- const params = type.details.parameters;
1325
+ const params = type.shared.parameters;
1208
1326
  if (params.length < 2) {
1209
1327
  return undefined;
1210
1328
  }
@@ -1212,28 +1330,18 @@ var FunctionType;
1212
1330
  const lastParam = params[params.length - 1];
1213
1331
  if (secondLastParam.category === 1 /* ParameterCategory.ArgsList */ &&
1214
1332
  isTypeVar(secondLastParam.type) &&
1215
- secondLastParam.type.paramSpecAccess === 'args' &&
1333
+ secondLastParam.type.priv.paramSpecAccess === 'args' &&
1216
1334
  lastParam.category === 2 /* ParameterCategory.KwargsDict */ &&
1217
1335
  isTypeVar(lastParam.type) &&
1218
- lastParam.type.paramSpecAccess === 'kwargs') {
1336
+ lastParam.type.priv.paramSpecAccess === 'kwargs') {
1219
1337
  return TypeVarType.cloneForParamSpecAccess(secondLastParam.type, /* access */ undefined);
1220
1338
  }
1221
1339
  return undefined;
1222
1340
  }
1223
1341
  FunctionType.getParamSpecFromArgsKwargs = getParamSpecFromArgsKwargs;
1224
1342
  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
- });
1343
+ FunctionType.addParameter(type, FunctionParam.create(1 /* ParameterCategory.ArgsList */, TypeVarType.cloneForParamSpecAccess(paramSpec, 'args'), FunctionParamFlags.TypeDeclared, 'args'));
1344
+ FunctionType.addParameter(type, FunctionParam.create(2 /* ParameterCategory.KwargsDict */, TypeVarType.cloneForParamSpecAccess(paramSpec, 'kwargs'), FunctionParamFlags.TypeDeclared, 'kwargs'));
1237
1345
  }
1238
1346
  FunctionType.addParamSpecVariadics = addParamSpecVariadics;
1239
1347
  function addDefaultParameters(type, useUnknown = false) {
@@ -1249,34 +1357,24 @@ var FunctionType;
1249
1357
  if (!Array.isArray(scopeIds)) {
1250
1358
  scopeIds = [scopeIds];
1251
1359
  }
1252
- if (!functionType.details.higherOrderTypeVarScopeIds) {
1253
- functionType.details.higherOrderTypeVarScopeIds = [];
1360
+ if (!functionType.priv.higherOrderTypeVarScopeIds) {
1361
+ functionType.priv.higherOrderTypeVarScopeIds = [];
1254
1362
  }
1255
1363
  // Add the scope IDs to the function if they're unique.
1256
1364
  scopeIds.forEach((scopeId) => {
1257
- if (!scopeId || scopeId === functionType.details.typeVarScopeId) {
1365
+ if (!scopeId || scopeId === functionType.shared.typeVarScopeId) {
1258
1366
  return;
1259
1367
  }
1260
- if (!functionType.details.higherOrderTypeVarScopeIds.some((id) => id === scopeId)) {
1261
- functionType.details.higherOrderTypeVarScopeIds.push(scopeId);
1368
+ if (!functionType.priv.higherOrderTypeVarScopeIds.some((id) => id === scopeId)) {
1369
+ functionType.priv.higherOrderTypeVarScopeIds.push(scopeId);
1262
1370
  }
1263
1371
  });
1264
1372
  }
1265
1373
  FunctionType.addHigherOrderTypeVarScopeIds = addHigherOrderTypeVarScopeIds;
1266
1374
  function getDefaultParameters(useUnknown = false) {
1267
1375
  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
- },
1376
+ FunctionParam.create(1 /* ParameterCategory.ArgsList */, useUnknown ? UnknownType.create() : AnyType.create(), useUnknown ? FunctionParamFlags.None : FunctionParamFlags.TypeDeclared, 'args'),
1377
+ FunctionParam.create(2 /* ParameterCategory.KwargsDict */, useUnknown ? UnknownType.create() : AnyType.create(), useUnknown ? FunctionParamFlags.None : FunctionParamFlags.TypeDeclared, 'kwargs'),
1280
1378
  ];
1281
1379
  }
1282
1380
  FunctionType.getDefaultParameters = getDefaultParameters;
@@ -1284,8 +1382,8 @@ var FunctionType;
1284
1382
  function hasDefaultParameters(functionType) {
1285
1383
  let sawArgs = false;
1286
1384
  let sawKwargs = false;
1287
- for (let i = 0; i < functionType.details.parameters.length; i++) {
1288
- const param = functionType.details.parameters[i];
1385
+ for (let i = 0; i < functionType.shared.parameters.length; i++) {
1386
+ const param = functionType.shared.parameters[i];
1289
1387
  // Ignore nameless separator parameters.
1290
1388
  if (!param.name) {
1291
1389
  continue;
@@ -1307,7 +1405,7 @@ var FunctionType;
1307
1405
  }
1308
1406
  FunctionType.hasDefaultParameters = hasDefaultParameters;
1309
1407
  function isInstanceMethod(type) {
1310
- return ((type.details.flags &
1408
+ return ((type.shared.flags &
1311
1409
  (1 /* FunctionTypeFlags.ConstructorMethod */ |
1312
1410
  4 /* FunctionTypeFlags.StaticMethod */ |
1313
1411
  2 /* FunctionTypeFlags.ClassMethod */)) ===
@@ -1315,128 +1413,134 @@ var FunctionType;
1315
1413
  }
1316
1414
  FunctionType.isInstanceMethod = isInstanceMethod;
1317
1415
  function isConstructorMethod(type) {
1318
- return (type.details.flags & 1 /* FunctionTypeFlags.ConstructorMethod */) !== 0;
1416
+ return (type.shared.flags & 1 /* FunctionTypeFlags.ConstructorMethod */) !== 0;
1319
1417
  }
1320
1418
  FunctionType.isConstructorMethod = isConstructorMethod;
1321
1419
  function isStaticMethod(type) {
1322
- return (type.details.flags & 4 /* FunctionTypeFlags.StaticMethod */) !== 0;
1420
+ return (type.shared.flags & 4 /* FunctionTypeFlags.StaticMethod */) !== 0;
1323
1421
  }
1324
1422
  FunctionType.isStaticMethod = isStaticMethod;
1325
1423
  function isClassMethod(type) {
1326
- return (type.details.flags & 2 /* FunctionTypeFlags.ClassMethod */) !== 0;
1424
+ return (type.shared.flags & 2 /* FunctionTypeFlags.ClassMethod */) !== 0;
1327
1425
  }
1328
1426
  FunctionType.isClassMethod = isClassMethod;
1329
1427
  function isAbstractMethod(type) {
1330
- return (type.details.flags & 8 /* FunctionTypeFlags.AbstractMethod */) !== 0;
1428
+ return (type.shared.flags & 8 /* FunctionTypeFlags.AbstractMethod */) !== 0;
1331
1429
  }
1332
1430
  FunctionType.isAbstractMethod = isAbstractMethod;
1333
1431
  function isGenerator(type) {
1334
- return (type.details.flags & 16 /* FunctionTypeFlags.Generator */) !== 0;
1432
+ return (type.shared.flags & 16 /* FunctionTypeFlags.Generator */) !== 0;
1335
1433
  }
1336
1434
  FunctionType.isGenerator = isGenerator;
1337
1435
  function isSynthesizedMethod(type) {
1338
- return (type.details.flags & 64 /* FunctionTypeFlags.SynthesizedMethod */) !== 0;
1436
+ return (type.shared.flags & 64 /* FunctionTypeFlags.SynthesizedMethod */) !== 0;
1339
1437
  }
1340
1438
  FunctionType.isSynthesizedMethod = isSynthesizedMethod;
1341
1439
  function isTypeCheckOnly(type) {
1342
- return (type.details.flags & 128 /* FunctionTypeFlags.TypeCheckOnly */) !== 0;
1440
+ return (type.shared.flags & 128 /* FunctionTypeFlags.TypeCheckOnly */) !== 0;
1343
1441
  }
1344
1442
  FunctionType.isTypeCheckOnly = isTypeCheckOnly;
1345
1443
  function isOverloaded(type) {
1346
- return (type.details.flags & 256 /* FunctionTypeFlags.Overloaded */) !== 0;
1444
+ return (type.shared.flags & 256 /* FunctionTypeFlags.Overloaded */) !== 0;
1347
1445
  }
1348
1446
  FunctionType.isOverloaded = isOverloaded;
1349
1447
  function isDefaultParameterCheckDisabled(type) {
1350
- return (type.details.flags & 32 /* FunctionTypeFlags.DisableDefaultChecks */) !== 0;
1448
+ return (type.shared.flags & 32 /* FunctionTypeFlags.DisableDefaultChecks */) !== 0;
1351
1449
  }
1352
1450
  FunctionType.isDefaultParameterCheckDisabled = isDefaultParameterCheckDisabled;
1353
1451
  function isAsync(type) {
1354
- return (type.details.flags & 512 /* FunctionTypeFlags.Async */) !== 0;
1452
+ return (type.shared.flags & 512 /* FunctionTypeFlags.Async */) !== 0;
1355
1453
  }
1356
1454
  FunctionType.isAsync = isAsync;
1357
1455
  function isStubDefinition(type) {
1358
- return (type.details.flags & 2048 /* FunctionTypeFlags.StubDefinition */) !== 0;
1456
+ return (type.shared.flags & 2048 /* FunctionTypeFlags.StubDefinition */) !== 0;
1359
1457
  }
1360
1458
  FunctionType.isStubDefinition = isStubDefinition;
1361
1459
  function isPyTypedDefinition(type) {
1362
- return (type.details.flags & 4096 /* FunctionTypeFlags.PyTypedDefinition */) !== 0;
1460
+ return (type.shared.flags & 4096 /* FunctionTypeFlags.PyTypedDefinition */) !== 0;
1363
1461
  }
1364
1462
  FunctionType.isPyTypedDefinition = isPyTypedDefinition;
1365
1463
  function isFinal(type) {
1366
- return (type.details.flags & 8192 /* FunctionTypeFlags.Final */) !== 0;
1464
+ return (type.shared.flags & 8192 /* FunctionTypeFlags.Final */) !== 0;
1367
1465
  }
1368
1466
  FunctionType.isFinal = isFinal;
1369
1467
  function hasUnannotatedParams(type) {
1370
- return (type.details.flags & 16384 /* FunctionTypeFlags.UnannotatedParams */) !== 0;
1468
+ return (type.shared.flags & 16384 /* FunctionTypeFlags.UnannotatedParams */) !== 0;
1371
1469
  }
1372
1470
  FunctionType.hasUnannotatedParams = hasUnannotatedParams;
1373
1471
  function isGradualCallableForm(type) {
1374
- return (type.details.flags & 32768 /* FunctionTypeFlags.GradualCallableForm */) !== 0;
1472
+ return (type.shared.flags & 32768 /* FunctionTypeFlags.GradualCallableForm */) !== 0;
1375
1473
  }
1376
1474
  FunctionType.isGradualCallableForm = isGradualCallableForm;
1377
1475
  function isParamSpecValue(type) {
1378
- return (type.details.flags & 65536 /* FunctionTypeFlags.ParamSpecValue */) !== 0;
1476
+ return (type.shared.flags & 65536 /* FunctionTypeFlags.ParamSpecValue */) !== 0;
1379
1477
  }
1380
1478
  FunctionType.isParamSpecValue = isParamSpecValue;
1381
1479
  function isPartiallyEvaluated(type) {
1382
- return !!(type.details.flags & 131072 /* FunctionTypeFlags.PartiallyEvaluated */);
1480
+ return !!(type.shared.flags & 131072 /* FunctionTypeFlags.PartiallyEvaluated */);
1383
1481
  }
1384
1482
  FunctionType.isPartiallyEvaluated = isPartiallyEvaluated;
1385
1483
  function isOverridden(type) {
1386
- return !!(type.details.flags & 262144 /* FunctionTypeFlags.Overridden */);
1484
+ return !!(type.shared.flags & 262144 /* FunctionTypeFlags.Overridden */);
1387
1485
  }
1388
1486
  FunctionType.isOverridden = isOverridden;
1487
+ function isBuiltIn(type, name) {
1488
+ if (!(type.shared.flags & 1048576 /* FunctionTypeFlags.BuiltIn */)) {
1489
+ return false;
1490
+ }
1491
+ if (name !== undefined) {
1492
+ const functionArray = Array.isArray(name) ? name : [name];
1493
+ return functionArray.some((name) => name === type.shared.name);
1494
+ }
1495
+ return true;
1496
+ }
1497
+ FunctionType.isBuiltIn = isBuiltIn;
1389
1498
  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];
1499
+ (0, debug_1.assert)(index < type.shared.parameters.length, 'Parameter types array overflow');
1500
+ if (type.priv.specializedTypes && index < type.priv.specializedTypes.parameterTypes.length) {
1501
+ return type.priv.specializedTypes.parameterTypes[index];
1393
1502
  }
1394
- return type.details.parameters[index].type;
1503
+ return type.shared.parameters[index].type;
1395
1504
  }
1396
1505
  FunctionType.getEffectiveParameterType = getEffectiveParameterType;
1397
1506
  function getEffectiveParameterDefaultArgType(type, index) {
1398
1507
  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];
1508
+ (0, debug_1.assert)(index < type.shared.parameters.length, 'Parameter types array overflow');
1509
+ if (((_a = type.priv.specializedTypes) === null || _a === void 0 ? void 0 : _a.parameterDefaultArgs) &&
1510
+ index < type.priv.specializedTypes.parameterDefaultArgs.length) {
1511
+ const defaultArgType = type.priv.specializedTypes.parameterDefaultArgs[index];
1402
1512
  if (defaultArgType) {
1403
1513
  return defaultArgType;
1404
1514
  }
1405
1515
  }
1406
- return type.details.parameters[index].defaultType;
1516
+ return type.shared.parameters[index].defaultType;
1407
1517
  }
1408
1518
  FunctionType.getEffectiveParameterDefaultArgType = getEffectiveParameterDefaultArgType;
1409
1519
  function addParameter(type, param) {
1410
- type.details.parameters.push(param);
1411
- if (type.specializedTypes) {
1412
- type.specializedTypes.parameterTypes.push(param.type);
1520
+ type.shared.parameters.push(param);
1521
+ if (type.priv.specializedTypes) {
1522
+ type.priv.specializedTypes.parameterTypes.push(param.type);
1413
1523
  }
1414
1524
  }
1415
1525
  FunctionType.addParameter = addParameter;
1416
1526
  function addPositionOnlyParameterSeparator(type) {
1417
- addParameter(type, {
1418
- category: 0 /* ParameterCategory.Simple */,
1419
- type: AnyType.create(),
1420
- });
1527
+ addParameter(type, FunctionParam.create(0 /* ParameterCategory.Simple */, AnyType.create()));
1421
1528
  }
1422
1529
  FunctionType.addPositionOnlyParameterSeparator = addPositionOnlyParameterSeparator;
1423
1530
  function addKeywordOnlyParameterSeparator(type) {
1424
- addParameter(type, {
1425
- category: 1 /* ParameterCategory.ArgsList */,
1426
- type: AnyType.create(),
1427
- });
1531
+ addParameter(type, FunctionParam.create(1 /* ParameterCategory.ArgsList */, AnyType.create()));
1428
1532
  }
1429
1533
  FunctionType.addKeywordOnlyParameterSeparator = addKeywordOnlyParameterSeparator;
1430
1534
  function getEffectiveReturnType(type, includeInferred = true) {
1431
1535
  var _a;
1432
- if ((_a = type.specializedTypes) === null || _a === void 0 ? void 0 : _a.returnType) {
1433
- return type.specializedTypes.returnType;
1536
+ if ((_a = type.priv.specializedTypes) === null || _a === void 0 ? void 0 : _a.returnType) {
1537
+ return type.priv.specializedTypes.returnType;
1434
1538
  }
1435
- if (type.details.declaredReturnType) {
1436
- return type.details.declaredReturnType;
1539
+ if (type.shared.declaredReturnType) {
1540
+ return type.shared.declaredReturnType;
1437
1541
  }
1438
1542
  if (includeInferred) {
1439
- return type.inferredReturnType;
1543
+ return type.priv.inferredReturnType;
1440
1544
  }
1441
1545
  return undefined;
1442
1546
  }
@@ -1447,8 +1551,13 @@ var OverloadedFunctionType;
1447
1551
  function create(overloads) {
1448
1552
  const newType = {
1449
1553
  category: 5 /* TypeCategory.OverloadedFunction */,
1450
- overloads: [],
1451
1554
  flags: 2 /* TypeFlags.Instance */,
1555
+ props: undefined,
1556
+ cached: undefined,
1557
+ shared: undefined,
1558
+ priv: {
1559
+ overloads: [],
1560
+ },
1452
1561
  };
1453
1562
  overloads.forEach((overload) => {
1454
1563
  OverloadedFunctionType.addOverload(newType, overload);
@@ -1458,16 +1567,16 @@ var OverloadedFunctionType;
1458
1567
  OverloadedFunctionType.create = create;
1459
1568
  // Adds a new overload or an implementation.
1460
1569
  function addOverload(type, functionType) {
1461
- functionType.overloaded = type;
1462
- type.overloads.push(functionType);
1570
+ functionType.priv.overloaded = type;
1571
+ type.priv.overloads.push(functionType);
1463
1572
  }
1464
1573
  OverloadedFunctionType.addOverload = addOverload;
1465
1574
  function getOverloads(type) {
1466
- return type.overloads.filter((func) => FunctionType.isOverloaded(func));
1575
+ return type.priv.overloads.filter((func) => FunctionType.isOverloaded(func));
1467
1576
  }
1468
1577
  OverloadedFunctionType.getOverloads = getOverloads;
1469
1578
  function getImplementation(type) {
1470
- return type.overloads.find((func) => !FunctionType.isOverloaded(func));
1579
+ return type.priv.overloads.find((func) => !FunctionType.isOverloaded(func));
1471
1580
  }
1472
1581
  OverloadedFunctionType.getImplementation = getImplementation;
1473
1582
  })(OverloadedFunctionType || (exports.OverloadedFunctionType = OverloadedFunctionType = {}));
@@ -1476,12 +1585,18 @@ var NeverType;
1476
1585
  const _neverInstance = {
1477
1586
  category: 3 /* TypeCategory.Never */,
1478
1587
  flags: 2 /* TypeFlags.Instance */ | 1 /* TypeFlags.Instantiable */,
1479
- isNoReturn: false,
1588
+ props: undefined,
1589
+ cached: undefined,
1590
+ shared: undefined,
1591
+ priv: { isNoReturn: false },
1480
1592
  };
1481
1593
  const _noReturnInstance = {
1482
1594
  category: 3 /* TypeCategory.Never */,
1483
1595
  flags: 2 /* TypeFlags.Instance */ | 1 /* TypeFlags.Instantiable */,
1484
- isNoReturn: true,
1596
+ props: undefined,
1597
+ cached: undefined,
1598
+ shared: undefined,
1599
+ priv: { isNoReturn: true },
1485
1600
  };
1486
1601
  function createNever() {
1487
1602
  return _neverInstance;
@@ -1492,11 +1607,12 @@ var NeverType;
1492
1607
  }
1493
1608
  NeverType.createNoReturn = createNoReturn;
1494
1609
  function convertToInstance(type) {
1610
+ var _a;
1495
1611
  // Remove the "special form" if present. Otherwise return the existing type.
1496
- if (!type.specialForm) {
1612
+ if (!((_a = type.props) === null || _a === void 0 ? void 0 : _a.specialForm)) {
1497
1613
  return type;
1498
1614
  }
1499
- return type.isNoReturn ? NeverType.createNoReturn() : NeverType.createNever();
1615
+ return type.priv.isNoReturn ? NeverType.createNoReturn() : NeverType.createNever();
1500
1616
  }
1501
1617
  NeverType.convertToInstance = convertToInstance;
1502
1618
  })(NeverType || (exports.NeverType = NeverType = {}));
@@ -1504,18 +1620,27 @@ var AnyType;
1504
1620
  (function (AnyType) {
1505
1621
  const _anyInstanceSpecialForm = {
1506
1622
  category: 2 /* TypeCategory.Any */,
1507
- isEllipsis: false,
1508
1623
  flags: 2 /* TypeFlags.Instance */ | 1 /* TypeFlags.Instantiable */,
1624
+ props: undefined,
1625
+ cached: undefined,
1626
+ shared: undefined,
1627
+ priv: { isEllipsis: false },
1509
1628
  };
1510
1629
  const _anyInstance = {
1511
1630
  category: 2 /* TypeCategory.Any */,
1512
- isEllipsis: false,
1513
1631
  flags: 2 /* TypeFlags.Instance */ | 1 /* TypeFlags.Instantiable */,
1632
+ props: undefined,
1633
+ cached: undefined,
1634
+ shared: undefined,
1635
+ priv: { isEllipsis: false },
1514
1636
  };
1515
1637
  const _ellipsisInstance = {
1516
1638
  category: 2 /* TypeCategory.Any */,
1517
- isEllipsis: true,
1518
1639
  flags: 2 /* TypeFlags.Instance */ | 1 /* TypeFlags.Instantiable */,
1640
+ props: undefined,
1641
+ cached: undefined,
1642
+ shared: undefined,
1643
+ priv: { isEllipsis: true },
1519
1644
  };
1520
1645
  function create(isEllipsis = false) {
1521
1646
  return isEllipsis ? _ellipsisInstance : _anyInstance;
@@ -1528,8 +1653,9 @@ var AnyType;
1528
1653
  })(AnyType || (exports.AnyType = AnyType = {}));
1529
1654
  (function (AnyType) {
1530
1655
  function convertToInstance(type) {
1656
+ var _a;
1531
1657
  // Remove the "special form" if present. Otherwise return the existing type.
1532
- return type.specialForm ? AnyType.create() : type;
1658
+ return ((_a = type.props) === null || _a === void 0 ? void 0 : _a.specialForm) ? AnyType.create() : type;
1533
1659
  }
1534
1660
  AnyType.convertToInstance = convertToInstance;
1535
1661
  })(AnyType || (exports.AnyType = AnyType = {}));
@@ -1554,10 +1680,10 @@ var TypeCondition;
1554
1680
  }
1555
1681
  TypeCondition.combine = combine;
1556
1682
  function _compare(c1, c2) {
1557
- if (c1.typeVar.details.name < c2.typeVar.details.name) {
1683
+ if (c1.typeVar.shared.name < c2.typeVar.shared.name) {
1558
1684
  return -1;
1559
1685
  }
1560
- else if (c1.typeVar.details.name > c2.typeVar.details.name) {
1686
+ else if (c1.typeVar.shared.name > c2.typeVar.shared.name) {
1561
1687
  return 1;
1562
1688
  }
1563
1689
  if (c1.constraintIndex < c2.constraintIndex) {
@@ -1575,7 +1701,7 @@ var TypeCondition;
1575
1701
  if (!conditions2 || conditions1.length !== conditions2.length) {
1576
1702
  return false;
1577
1703
  }
1578
- return (conditions1.find((c1, index) => c1.typeVar.nameWithScope !== conditions2[index].typeVar.nameWithScope ||
1704
+ return (conditions1.find((c1, index) => c1.typeVar.priv.nameWithScope !== conditions2[index].typeVar.priv.nameWithScope ||
1579
1705
  c1.constraintIndex !== conditions2[index].constraintIndex) === undefined);
1580
1706
  }
1581
1707
  TypeCondition.isSame = isSame;
@@ -1590,7 +1716,7 @@ var TypeCondition;
1590
1716
  for (const c1 of conditions1) {
1591
1717
  let foundTypeVarMatch = false;
1592
1718
  const exactMatch = conditions2.find((c2) => {
1593
- if (c1.typeVar.nameWithScope === c2.typeVar.nameWithScope) {
1719
+ if (c1.typeVar.priv.nameWithScope === c2.typeVar.priv.nameWithScope) {
1594
1720
  foundTypeVarMatch = true;
1595
1721
  return c1.constraintIndex === c2.constraintIndex;
1596
1722
  }
@@ -1609,46 +1735,64 @@ var UnionType;
1609
1735
  function create() {
1610
1736
  const newUnionType = {
1611
1737
  category: 8 /* TypeCategory.Union */,
1612
- subtypes: [],
1613
- literalInstances: {},
1614
- literalClasses: {},
1615
1738
  flags: 2 /* TypeFlags.Instance */ | 1 /* TypeFlags.Instantiable */,
1739
+ props: undefined,
1740
+ cached: undefined,
1741
+ shared: undefined,
1742
+ priv: {
1743
+ subtypes: [],
1744
+ literalInstances: {
1745
+ literalStrMap: undefined,
1746
+ literalIntMap: undefined,
1747
+ literalEnumMap: undefined,
1748
+ },
1749
+ literalClasses: {
1750
+ literalStrMap: undefined,
1751
+ literalIntMap: undefined,
1752
+ literalEnumMap: undefined,
1753
+ },
1754
+ typeAliasSources: undefined,
1755
+ includesRecursiveTypeAlias: false,
1756
+ },
1616
1757
  };
1617
1758
  return newUnionType;
1618
1759
  }
1619
1760
  UnionType.create = create;
1620
1761
  function addType(unionType, newType) {
1762
+ var _a, _b;
1621
1763
  // If we're adding a string, integer or enum literal, add it to the
1622
1764
  // corresponding literal map to speed up some operations. It's not
1623
1765
  // 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;
1766
+ if (isClass(newType) && newType.priv.literalValue !== undefined && !((_a = newType.props) === null || _a === void 0 ? void 0 : _a.condition)) {
1767
+ const literalMaps = isClassInstance(newType)
1768
+ ? unionType.priv.literalInstances
1769
+ : unionType.priv.literalClasses;
1626
1770
  if (ClassType.isBuiltIn(newType, 'str')) {
1627
1771
  if (literalMaps.literalStrMap === undefined) {
1628
1772
  literalMaps.literalStrMap = new Map();
1629
1773
  }
1630
- literalMaps.literalStrMap.set(newType.literalValue, newType);
1774
+ literalMaps.literalStrMap.set(newType.priv.literalValue, newType);
1631
1775
  }
1632
1776
  else if (ClassType.isBuiltIn(newType, 'int')) {
1633
1777
  if (literalMaps.literalIntMap === undefined) {
1634
1778
  literalMaps.literalIntMap = new Map();
1635
1779
  }
1636
- literalMaps.literalIntMap.set(newType.literalValue, newType);
1780
+ literalMaps.literalIntMap.set(newType.priv.literalValue, newType);
1637
1781
  }
1638
1782
  else if (ClassType.isEnumClass(newType)) {
1639
1783
  if (literalMaps.literalEnumMap === undefined) {
1640
1784
  literalMaps.literalEnumMap = new Map();
1641
1785
  }
1642
- const enumLiteral = newType.literalValue;
1786
+ const enumLiteral = newType.priv.literalValue;
1643
1787
  literalMaps.literalEnumMap.set(enumLiteral.getName(), newType);
1644
1788
  }
1645
1789
  }
1646
1790
  unionType.flags &= newType.flags;
1647
- unionType.subtypes.push(newType);
1648
- if (isTypeVar(newType) && newType.details.recursiveTypeAliasName) {
1791
+ unionType.priv.subtypes.push(newType);
1792
+ if (isTypeVar(newType) && ((_b = newType.shared.recursiveAlias) === null || _b === void 0 ? void 0 : _b.name)) {
1649
1793
  // Note that at least one recursive type alias was included in
1650
1794
  // this union. We'll need to expand it before the union is used.
1651
- unionType.includesRecursiveTypeAlias = true;
1795
+ unionType.priv.includesRecursiveTypeAlias = true;
1652
1796
  }
1653
1797
  }
1654
1798
  UnionType.addType = addType;
@@ -1656,22 +1800,25 @@ var UnionType;
1656
1800
  // the method skips any subtype indexes that are in the set and adds a found index to
1657
1801
  // the exclusion set. This speeds up union type comparisons.
1658
1802
  function containsType(unionType, subtype, exclusionSet, recursionCount = 0) {
1803
+ var _a;
1659
1804
  // Handle string literals as a special case because unions can sometimes
1660
1805
  // 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;
1806
+ if (isClass(subtype) && ((_a = subtype.props) === null || _a === void 0 ? void 0 : _a.condition) === undefined && subtype.priv.literalValue !== undefined) {
1807
+ const literalMaps = isClassInstance(subtype)
1808
+ ? unionType.priv.literalInstances
1809
+ : unionType.priv.literalClasses;
1663
1810
  if (ClassType.isBuiltIn(subtype, 'str') && literalMaps.literalStrMap !== undefined) {
1664
- return literalMaps.literalStrMap.has(subtype.literalValue);
1811
+ return literalMaps.literalStrMap.has(subtype.priv.literalValue);
1665
1812
  }
1666
1813
  else if (ClassType.isBuiltIn(subtype, 'int') && literalMaps.literalIntMap !== undefined) {
1667
- return literalMaps.literalIntMap.has(subtype.literalValue);
1814
+ return literalMaps.literalIntMap.has(subtype.priv.literalValue);
1668
1815
  }
1669
1816
  else if (ClassType.isEnumClass(subtype) && literalMaps.literalEnumMap !== undefined) {
1670
- const enumLiteral = subtype.literalValue;
1817
+ const enumLiteral = subtype.priv.literalValue;
1671
1818
  return literalMaps.literalEnumMap.has(enumLiteral.getName());
1672
1819
  }
1673
1820
  }
1674
- const foundIndex = unionType.subtypes.findIndex((t, i) => {
1821
+ const foundIndex = unionType.priv.subtypes.findIndex((t, i) => {
1675
1822
  if (exclusionSet === null || exclusionSet === void 0 ? void 0 : exclusionSet.has(i)) {
1676
1823
  return false;
1677
1824
  }
@@ -1685,14 +1832,17 @@ var UnionType;
1685
1832
  }
1686
1833
  UnionType.containsType = containsType;
1687
1834
  function addTypeAliasSource(unionType, typeAliasSource) {
1835
+ var _a;
1688
1836
  if (typeAliasSource.category === 8 /* TypeCategory.Union */) {
1689
- const sourcesToAdd = typeAliasSource.typeAliasInfo ? [typeAliasSource] : typeAliasSource.typeAliasSources;
1837
+ const sourcesToAdd = ((_a = typeAliasSource.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo)
1838
+ ? [typeAliasSource]
1839
+ : typeAliasSource.priv.typeAliasSources;
1690
1840
  if (sourcesToAdd) {
1691
- if (!unionType.typeAliasSources) {
1692
- unionType.typeAliasSources = new Set();
1841
+ if (!unionType.priv.typeAliasSources) {
1842
+ unionType.priv.typeAliasSources = new Set();
1693
1843
  }
1694
1844
  sourcesToAdd.forEach((source) => {
1695
- unionType.typeAliasSources.add(source);
1845
+ unionType.priv.typeAliasSources.add(source);
1696
1846
  });
1697
1847
  }
1698
1848
  }
@@ -1724,13 +1874,15 @@ var TypeVarType;
1724
1874
  }
1725
1875
  TypeVarType.createInstantiable = createInstantiable;
1726
1876
  function cloneAsInstance(type) {
1727
- var _a;
1877
+ var _a, _b;
1728
1878
  (0, debug_1.assert)(TypeBase.isInstantiable(type));
1729
1879
  if ((_a = type.cached) === null || _a === void 0 ? void 0 : _a.typeBaseInstanceType) {
1730
1880
  return type.cached.typeBaseInstanceType;
1731
1881
  }
1732
1882
  const newInstance = TypeBase.cloneTypeAsInstance(type, /* cache */ true);
1733
- delete newInstance.specialForm;
1883
+ if ((_b = newInstance.props) === null || _b === void 0 ? void 0 : _b.specialForm) {
1884
+ TypeBase.setSpecialForm(newInstance, undefined);
1885
+ }
1734
1886
  return newInstance;
1735
1887
  }
1736
1888
  TypeVarType.cloneAsInstance = cloneAsInstance;
@@ -1745,36 +1897,36 @@ var TypeVarType;
1745
1897
  TypeVarType.cloneAsInstantiable = cloneAsInstantiable;
1746
1898
  function cloneForNewName(type, name) {
1747
1899
  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);
1900
+ newInstance.shared = { ...type.shared };
1901
+ newInstance.shared.name = name;
1902
+ if (newInstance.priv.scopeId) {
1903
+ newInstance.priv.nameWithScope = makeNameWithScope(name, newInstance.priv.scopeId);
1752
1904
  }
1753
1905
  return newInstance;
1754
1906
  }
1755
1907
  TypeVarType.cloneForNewName = cloneForNewName;
1756
1908
  function cloneForScopeId(type, scopeId, scopeName, scopeType) {
1757
1909
  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;
1910
+ newInstance.priv.nameWithScope = makeNameWithScope(type.shared.name, scopeId);
1911
+ newInstance.priv.scopeId = scopeId;
1912
+ newInstance.priv.scopeName = scopeName;
1913
+ newInstance.priv.scopeType = scopeType;
1762
1914
  return newInstance;
1763
1915
  }
1764
1916
  TypeVarType.cloneForScopeId = cloneForScopeId;
1765
1917
  function cloneForUnpacked(type, isInUnion = false) {
1766
- (0, debug_1.assert)(type.details.isVariadic);
1918
+ (0, debug_1.assert)(type.shared.isVariadic);
1767
1919
  const newInstance = TypeBase.cloneType(type);
1768
- newInstance.isVariadicUnpacked = true;
1769
- newInstance.isVariadicInUnion = isInUnion;
1920
+ newInstance.priv.isVariadicUnpacked = true;
1921
+ newInstance.priv.isVariadicInUnion = isInUnion;
1770
1922
  return newInstance;
1771
1923
  }
1772
1924
  TypeVarType.cloneForUnpacked = cloneForUnpacked;
1773
1925
  function cloneForPacked(type) {
1774
- (0, debug_1.assert)(type.details.isVariadic);
1926
+ (0, debug_1.assert)(type.shared.isVariadic);
1775
1927
  const newInstance = TypeBase.cloneType(type);
1776
- newInstance.isVariadicUnpacked = false;
1777
- newInstance.isVariadicInUnion = false;
1928
+ newInstance.priv.isVariadicUnpacked = false;
1929
+ newInstance.priv.isVariadicInUnion = false;
1778
1930
  return newInstance;
1779
1931
  }
1780
1932
  TypeVarType.cloneForPacked = cloneForPacked;
@@ -1782,55 +1934,55 @@ var TypeVarType;
1782
1934
  // and no bound or constraints. ParamSpecs and variadics are left
1783
1935
  // unmodified. So are auto-variant type variables.
1784
1936
  function cloneAsInvariant(type) {
1785
- if (type.details.isParamSpec || type.details.isVariadic) {
1937
+ if (type.shared.isParamSpec || type.shared.isVariadic) {
1786
1938
  return type;
1787
1939
  }
1788
- if (type.details.declaredVariance === 0 /* Variance.Auto */) {
1940
+ if (type.shared.declaredVariance === 0 /* Variance.Auto */) {
1789
1941
  return type;
1790
1942
  }
1791
- if (type.details.declaredVariance === 2 /* Variance.Invariant */) {
1792
- if (type.details.boundType === undefined && type.details.constraints.length === 0) {
1943
+ if (type.shared.declaredVariance === 2 /* Variance.Invariant */) {
1944
+ if (type.shared.boundType === undefined && type.shared.constraints.length === 0) {
1793
1945
  return type;
1794
1946
  }
1795
1947
  }
1796
1948
  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 = [];
1949
+ newInstance.shared = { ...newInstance.shared };
1950
+ newInstance.shared.declaredVariance = 2 /* Variance.Invariant */;
1951
+ newInstance.shared.boundType = undefined;
1952
+ newInstance.shared.constraints = [];
1801
1953
  return newInstance;
1802
1954
  }
1803
1955
  TypeVarType.cloneAsInvariant = cloneAsInvariant;
1804
1956
  function cloneForParamSpecAccess(type, access) {
1805
1957
  const newInstance = TypeBase.cloneType(type);
1806
- newInstance.paramSpecAccess = access;
1958
+ newInstance.priv.paramSpecAccess = access;
1807
1959
  return newInstance;
1808
1960
  }
1809
1961
  TypeVarType.cloneForParamSpecAccess = cloneForParamSpecAccess;
1810
1962
  function cloneAsSpecializedSelf(type, specializedBoundType) {
1811
- (0, debug_1.assert)(type.details.isSynthesizedSelf);
1963
+ (0, debug_1.assert)(type.shared.isSynthesizedSelf);
1812
1964
  const newInstance = TypeBase.cloneType(type);
1813
- newInstance.details = { ...newInstance.details };
1814
- newInstance.details.boundType = specializedBoundType;
1965
+ newInstance.shared = { ...newInstance.shared };
1966
+ newInstance.shared.boundType = specializedBoundType;
1815
1967
  return newInstance;
1816
1968
  }
1817
1969
  TypeVarType.cloneAsSpecializedSelf = cloneAsSpecializedSelf;
1818
1970
  function cloneAsInScopePlaceholder(type, usageOffset) {
1819
- if (type.isInScopePlaceholder) {
1971
+ if (type.priv.isInScopePlaceholder) {
1820
1972
  return type;
1821
1973
  }
1822
1974
  // If the caller specified a usage offset, append it to the TypeVar
1823
1975
  // internal name. This allows us to distinguish it from other uses
1824
1976
  // of the same TypeVar. For example nested calls to a generic
1825
1977
  // function like `foo(foo(1))`.
1826
- let newNameWithScope = type.nameWithScope;
1978
+ let newNameWithScope = type.priv.nameWithScope;
1827
1979
  if (usageOffset) {
1828
- newNameWithScope = `${type.nameWithScope}-${usageOffset}`;
1980
+ newNameWithScope = `${type.priv.nameWithScope}-${usageOffset}`;
1829
1981
  }
1830
1982
  const newInstance = TypeBase.cloneType(type);
1831
- newInstance.isInScopePlaceholder = true;
1832
- newInstance.scopeId = exports.InScopePlaceholderScopeId;
1833
- newInstance.nameWithScope = newNameWithScope;
1983
+ newInstance.priv.isInScopePlaceholder = true;
1984
+ newInstance.priv.scopeId = exports.InScopePlaceholderScopeId;
1985
+ newInstance.priv.nameWithScope = newNameWithScope;
1834
1986
  return newInstance;
1835
1987
  }
1836
1988
  TypeVarType.cloneAsInScopePlaceholder = cloneAsInScopePlaceholder;
@@ -1841,38 +1993,48 @@ var TypeVarType;
1841
1993
  function create(name, isParamSpec, typeFlags) {
1842
1994
  const newTypeVarType = {
1843
1995
  category: 9 /* TypeCategory.TypeVar */,
1844
- details: {
1996
+ flags: typeFlags,
1997
+ props: undefined,
1998
+ cached: undefined,
1999
+ shared: {
1845
2000
  name,
1846
2001
  constraints: [],
1847
- declaredVariance: 2 /* Variance.Invariant */,
2002
+ boundType: undefined,
2003
+ isDefaultExplicit: false,
2004
+ defaultType: UnknownType.create(),
1848
2005
  isParamSpec,
1849
2006
  isVariadic: false,
2007
+ declaredVariance: 2 /* Variance.Invariant */,
1850
2008
  isSynthesized: false,
1851
- defaultType: UnknownType.create(),
2009
+ isSynthesizedSelf: false,
2010
+ synthesizedIndex: undefined,
2011
+ isExemptFromBoundCheck: false,
2012
+ isTypeParamSyntax: false,
2013
+ recursiveAlias: undefined,
1852
2014
  },
1853
- flags: typeFlags,
2015
+ priv: {},
1854
2016
  };
1855
2017
  return newTypeVarType;
1856
2018
  }
1857
2019
  function addConstraint(typeVarType, constraintType) {
1858
- typeVarType.details.constraints.push(constraintType);
2020
+ typeVarType.shared.constraints.push(constraintType);
1859
2021
  }
1860
2022
  TypeVarType.addConstraint = addConstraint;
1861
2023
  function getNameWithScope(typeVarType) {
1862
2024
  // If there is no name with scope, fall back on the (unscoped) name.
1863
- return typeVarType.nameWithScope || typeVarType.details.name;
2025
+ return typeVarType.priv.nameWithScope || typeVarType.shared.name;
1864
2026
  }
1865
2027
  TypeVarType.getNameWithScope = getNameWithScope;
1866
2028
  function getReadableName(typeVarType) {
1867
- if (typeVarType.scopeName) {
1868
- return `${typeVarType.details.name}@${typeVarType.scopeName}`;
2029
+ if (typeVarType.priv.scopeName) {
2030
+ return `${typeVarType.shared.name}@${typeVarType.priv.scopeName}`;
1869
2031
  }
1870
- return typeVarType.details.name;
2032
+ return typeVarType.shared.name;
1871
2033
  }
1872
2034
  TypeVarType.getReadableName = getReadableName;
1873
2035
  function getVariance(type) {
1874
2036
  var _a;
1875
- const variance = (_a = type.computedVariance) !== null && _a !== void 0 ? _a : type.details.declaredVariance;
2037
+ const variance = (_a = type.priv.computedVariance) !== null && _a !== void 0 ? _a : type.shared.declaredVariance;
1876
2038
  // By this point, the variance should have been inferred.
1877
2039
  (0, debug_1.assert)(variance !== 0 /* Variance.Auto */, 'Expected variance to be inferred');
1878
2040
  // If we're in the process of computing variance, it will still be
@@ -1886,7 +2048,7 @@ var TypeVarType;
1886
2048
  // Indicates whether the specified type is a recursive type alias
1887
2049
  // placeholder that has not yet been resolved.
1888
2050
  function isTypeAliasPlaceholder(type) {
1889
- return !!type.details.recursiveTypeAliasName && !type.details.boundType;
2051
+ return !!type.shared.recursiveAlias && !type.shared.boundType;
1890
2052
  }
1891
2053
  TypeVarType.isTypeAliasPlaceholder = isTypeAliasPlaceholder;
1892
2054
  })(TypeVarType || (exports.TypeVarType = TypeVarType = {}));
@@ -1907,7 +2069,7 @@ function isAnyOrUnknown(type) {
1907
2069
  return true;
1908
2070
  }
1909
2071
  if (isUnion(type)) {
1910
- return type.subtypes.find((subtype) => !isAnyOrUnknown(subtype)) === undefined;
2072
+ return type.priv.subtypes.find((subtype) => !isAnyOrUnknown(subtype)) === undefined;
1911
2073
  }
1912
2074
  return false;
1913
2075
  }
@@ -1925,7 +2087,7 @@ function isPossiblyUnbound(type) {
1925
2087
  return true;
1926
2088
  }
1927
2089
  if (isUnion(type)) {
1928
- return type.subtypes.find((subtype) => isPossiblyUnbound(subtype)) !== undefined;
2090
+ return type.priv.subtypes.find((subtype) => isPossiblyUnbound(subtype)) !== undefined;
1929
2091
  }
1930
2092
  return false;
1931
2093
  }
@@ -1951,18 +2113,18 @@ function isTypeVar(type) {
1951
2113
  }
1952
2114
  exports.isTypeVar = isTypeVar;
1953
2115
  function isVariadicTypeVar(type) {
1954
- return type.category === 9 /* TypeCategory.TypeVar */ && type.details.isVariadic;
2116
+ return type.category === 9 /* TypeCategory.TypeVar */ && type.shared.isVariadic;
1955
2117
  }
1956
2118
  exports.isVariadicTypeVar = isVariadicTypeVar;
1957
2119
  function isUnpackedVariadicTypeVar(type) {
1958
2120
  return (type.category === 9 /* TypeCategory.TypeVar */ &&
1959
- type.details.isVariadic &&
1960
- !!type.isVariadicUnpacked &&
1961
- !type.isVariadicInUnion);
2121
+ type.shared.isVariadic &&
2122
+ !!type.priv.isVariadicUnpacked &&
2123
+ !type.priv.isVariadicInUnion);
1962
2124
  }
1963
2125
  exports.isUnpackedVariadicTypeVar = isUnpackedVariadicTypeVar;
1964
2126
  function isUnpackedClass(type) {
1965
- if (!isClass(type) || !type.isUnpacked) {
2127
+ if (!isClass(type) || !type.priv.isUnpacked) {
1966
2128
  return false;
1967
2129
  }
1968
2130
  return true;
@@ -1973,7 +2135,7 @@ function isUnpacked(type) {
1973
2135
  }
1974
2136
  exports.isUnpacked = isUnpacked;
1975
2137
  function isParamSpec(type) {
1976
- return type.category === 9 /* TypeCategory.TypeVar */ && type.details.isParamSpec;
2138
+ return type.category === 9 /* TypeCategory.TypeVar */ && type.shared.isParamSpec;
1977
2139
  }
1978
2140
  exports.isParamSpec = isParamSpec;
1979
2141
  function isFunction(type) {
@@ -1985,14 +2147,15 @@ function isOverloadedFunction(type) {
1985
2147
  }
1986
2148
  exports.isOverloadedFunction = isOverloadedFunction;
1987
2149
  function getTypeAliasInfo(type) {
1988
- if (type.typeAliasInfo) {
1989
- return type.typeAliasInfo;
2150
+ var _a, _b;
2151
+ if ((_a = type.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo) {
2152
+ return type.props.typeAliasInfo;
1990
2153
  }
1991
2154
  if (isTypeVar(type) &&
1992
- type.details.recursiveTypeAliasName &&
1993
- type.details.boundType &&
1994
- type.details.boundType.typeAliasInfo) {
1995
- return type.details.boundType.typeAliasInfo;
2155
+ type.shared.recursiveAlias &&
2156
+ type.shared.boundType &&
2157
+ ((_b = type.shared.boundType.props) === null || _b === void 0 ? void 0 : _b.typeAliasInfo)) {
2158
+ return type.shared.boundType.props.typeAliasInfo;
1996
2159
  }
1997
2160
  return undefined;
1998
2161
  }
@@ -2001,7 +2164,7 @@ exports.getTypeAliasInfo = getTypeAliasInfo;
2001
2164
  // type arguments for "pseudo-generic" classes (non-generic classes whose init
2002
2165
  // methods are not annotated and are therefore treated as generic) are ignored.
2003
2166
  function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2004
- var _a, _b;
2167
+ var _a, _b, _c, _d, _e, _f;
2005
2168
  if (type1 === type2) {
2006
2169
  return true;
2007
2170
  }
@@ -2017,7 +2180,7 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2017
2180
  return false;
2018
2181
  }
2019
2182
  if (!options.ignoreTypeFlags) {
2020
- if (type1.flags !== type2.flags) {
2183
+ if ((type1.flags & 3 /* TypeFlags.TypeCompatibilityMask */) !== (type2.flags & 3 /* TypeFlags.TypeCompatibilityMask */)) {
2021
2184
  return false;
2022
2185
  }
2023
2186
  }
@@ -2032,14 +2195,14 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2032
2195
  if (!ClassType.isSameGenericClass(type1, classType2, recursionCount)) {
2033
2196
  return false;
2034
2197
  }
2035
- if (!options.ignoreConditions && !TypeCondition.isSame(type1.condition, type2.condition)) {
2198
+ 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
2199
  return false;
2037
2200
  }
2038
2201
  if (!options.ignorePseudoGeneric || !ClassType.isPseudoGenericClass(type1)) {
2039
2202
  // Make sure the type args match.
2040
- if (type1.tupleTypeArguments && classType2.tupleTypeArguments) {
2041
- const type1TupleTypeArgs = type1.tupleTypeArguments || [];
2042
- const type2TupleTypeArgs = classType2.tupleTypeArguments || [];
2203
+ if (type1.priv.tupleTypeArguments && classType2.priv.tupleTypeArguments) {
2204
+ const type1TupleTypeArgs = type1.priv.tupleTypeArguments || [];
2205
+ const type2TupleTypeArgs = classType2.priv.tupleTypeArguments || [];
2043
2206
  if (type1TupleTypeArgs.length !== type2TupleTypeArgs.length) {
2044
2207
  return false;
2045
2208
  }
@@ -2053,8 +2216,8 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2053
2216
  }
2054
2217
  }
2055
2218
  else {
2056
- const type1TypeArgs = type1.typeArguments || [];
2057
- const type2TypeArgs = classType2.typeArguments || [];
2219
+ const type1TypeArgs = type1.priv.typeArguments || [];
2220
+ const type2TypeArgs = classType2.priv.typeArguments || [];
2058
2221
  const typeArgCount = Math.max(type1TypeArgs.length, type2TypeArgs.length);
2059
2222
  for (let i = 0; i < typeArgCount; i++) {
2060
2223
  // Assume that missing type args are "Unknown".
@@ -2069,7 +2232,7 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2069
2232
  if (!ClassType.isLiteralValueSame(type1, classType2)) {
2070
2233
  return false;
2071
2234
  }
2072
- if (!type1.isTypedDictPartial !== !classType2.isTypedDictPartial) {
2235
+ if (!type1.priv.isTypedDictPartial !== !classType2.priv.isTypedDictPartial) {
2073
2236
  return false;
2074
2237
  }
2075
2238
  if (!options.ignoreTypedDictNarrowEntries && !ClassType.isTypedDictNarrowedEntriesSame(type1, classType2)) {
@@ -2080,8 +2243,8 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2080
2243
  case 4 /* TypeCategory.Function */: {
2081
2244
  // Make sure the parameter counts match.
2082
2245
  const functionType2 = type2;
2083
- const params1 = type1.details.parameters;
2084
- const params2 = functionType2.details.parameters;
2246
+ const params1 = type1.shared.parameters;
2247
+ const params2 = functionType2.shared.parameters;
2085
2248
  if (params1.length !== params2.length) {
2086
2249
  return false;
2087
2250
  }
@@ -2121,19 +2284,19 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2121
2284
  }
2122
2285
  }
2123
2286
  // Make sure the return types match.
2124
- let return1Type = type1.details.declaredReturnType;
2125
- if (type1.specializedTypes && type1.specializedTypes.returnType) {
2126
- return1Type = type1.specializedTypes.returnType;
2287
+ let return1Type = type1.shared.declaredReturnType;
2288
+ if (type1.priv.specializedTypes && type1.priv.specializedTypes.returnType) {
2289
+ return1Type = type1.priv.specializedTypes.returnType;
2127
2290
  }
2128
- if (!return1Type && type1.inferredReturnType) {
2129
- return1Type = type1.inferredReturnType;
2291
+ if (!return1Type && type1.priv.inferredReturnType) {
2292
+ return1Type = type1.priv.inferredReturnType;
2130
2293
  }
2131
- let return2Type = functionType2.details.declaredReturnType;
2132
- if (functionType2.specializedTypes && functionType2.specializedTypes.returnType) {
2133
- return2Type = functionType2.specializedTypes.returnType;
2294
+ let return2Type = functionType2.shared.declaredReturnType;
2295
+ if (functionType2.priv.specializedTypes && functionType2.priv.specializedTypes.returnType) {
2296
+ return2Type = functionType2.priv.specializedTypes.returnType;
2134
2297
  }
2135
- if (!return2Type && functionType2.inferredReturnType) {
2136
- return2Type = functionType2.inferredReturnType;
2298
+ if (!return2Type && functionType2.priv.inferredReturnType) {
2299
+ return2Type = functionType2.priv.inferredReturnType;
2137
2300
  }
2138
2301
  if (return1Type || return2Type) {
2139
2302
  if (!return1Type ||
@@ -2147,13 +2310,13 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2147
2310
  case 5 /* TypeCategory.OverloadedFunction */: {
2148
2311
  // Make sure the overload counts match.
2149
2312
  const functionType2 = type2;
2150
- if (type1.overloads.length !== functionType2.overloads.length) {
2313
+ if (type1.priv.overloads.length !== functionType2.priv.overloads.length) {
2151
2314
  return false;
2152
2315
  }
2153
2316
  // We assume here that overloaded functions always appear
2154
2317
  // 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)) {
2318
+ for (let i = 0; i < type1.priv.overloads.length; i++) {
2319
+ if (!isTypeSame(type1.priv.overloads[i], functionType2.priv.overloads[i], options, recursionCount)) {
2157
2320
  return false;
2158
2321
  }
2159
2322
  }
@@ -2161,8 +2324,8 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2161
2324
  }
2162
2325
  case 8 /* TypeCategory.Union */: {
2163
2326
  const unionType2 = type2;
2164
- const subtypes1 = type1.subtypes;
2165
- const subtypes2 = unionType2.subtypes;
2327
+ const subtypes1 = type1.priv.subtypes;
2328
+ const subtypes2 = unionType2.priv.subtypes;
2166
2329
  if (subtypes1.length !== subtypes2.length) {
2167
2330
  return false;
2168
2331
  }
@@ -2173,14 +2336,14 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2173
2336
  }
2174
2337
  case 9 /* TypeCategory.TypeVar */: {
2175
2338
  const type2TypeVar = type2;
2176
- if (type1.scopeId !== type2TypeVar.scopeId) {
2339
+ if (type1.priv.scopeId !== type2TypeVar.priv.scopeId) {
2177
2340
  return false;
2178
2341
  }
2179
2342
  // Handle the case where this is a generic recursive type alias. Make
2180
2343
  // 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) || [];
2344
+ if (type1.shared.recursiveAlias && type2TypeVar.shared.recursiveAlias) {
2345
+ 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) || [];
2346
+ 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
2347
  const typeArgCount = Math.max(type1TypeArgs.length, type2TypeArgs.length);
2185
2348
  for (let i = 0; i < typeArgCount; i++) {
2186
2349
  // Assume that missing type args are "Any".
@@ -2191,22 +2354,22 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2191
2354
  }
2192
2355
  }
2193
2356
  }
2194
- if (!type1.isVariadicInUnion !== !type2TypeVar.isVariadicInUnion) {
2357
+ if (!type1.priv.isVariadicInUnion !== !type2TypeVar.priv.isVariadicInUnion) {
2195
2358
  return false;
2196
2359
  }
2197
- if (type1.details === type2TypeVar.details) {
2360
+ if (type1.shared === type2TypeVar.shared) {
2198
2361
  return true;
2199
2362
  }
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) {
2363
+ if (type1.shared.name !== type2TypeVar.shared.name ||
2364
+ type1.shared.isParamSpec !== type2TypeVar.shared.isParamSpec ||
2365
+ type1.shared.isVariadic !== type2TypeVar.shared.isVariadic ||
2366
+ type1.shared.isSynthesized !== type2TypeVar.shared.isSynthesized ||
2367
+ type1.shared.declaredVariance !== type2TypeVar.shared.declaredVariance ||
2368
+ type1.priv.scopeId !== type2TypeVar.priv.scopeId) {
2206
2369
  return false;
2207
2370
  }
2208
- const boundType1 = type1.details.boundType;
2209
- const boundType2 = type2TypeVar.details.boundType;
2371
+ const boundType1 = type1.shared.boundType;
2372
+ const boundType2 = type2TypeVar.shared.boundType;
2210
2373
  if (boundType1) {
2211
2374
  if (!boundType2 ||
2212
2375
  !isTypeSame(boundType1, boundType2, { ...options, ignoreTypeFlags: false }, recursionCount)) {
@@ -2218,8 +2381,8 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2218
2381
  return false;
2219
2382
  }
2220
2383
  }
2221
- const constraints1 = type1.details.constraints;
2222
- const constraints2 = type2TypeVar.details.constraints;
2384
+ const constraints1 = type1.shared.constraints;
2385
+ const constraints2 = type2TypeVar.shared.constraints;
2223
2386
  if (constraints1.length !== constraints2.length) {
2224
2387
  return false;
2225
2388
  }
@@ -2234,19 +2397,19 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2234
2397
  const type2Module = type2;
2235
2398
  // Module types are the same if they share the same
2236
2399
  // module symbol table.
2237
- if (type1.fields === type2Module.fields) {
2400
+ if (type1.priv.fields === type2Module.priv.fields) {
2238
2401
  return true;
2239
2402
  }
2240
2403
  // If both symbol tables are empty, we can also assume
2241
2404
  // they're equal.
2242
- if (type1.fields.size === 0 && type2Module.fields.size === 0) {
2405
+ if (type1.priv.fields.size === 0 && type2Module.priv.fields.size === 0) {
2243
2406
  return true;
2244
2407
  }
2245
2408
  return false;
2246
2409
  }
2247
2410
  case 1 /* TypeCategory.Unknown */: {
2248
2411
  const type2Unknown = type2;
2249
- return type1.isIncomplete === type2Unknown.isIncomplete;
2412
+ return type1.priv.isIncomplete === type2Unknown.priv.isIncomplete;
2250
2413
  }
2251
2414
  }
2252
2415
  return true;
@@ -2272,8 +2435,8 @@ function removeUnbound(type) {
2272
2435
  exports.removeUnbound = removeUnbound;
2273
2436
  function removeFromUnion(type, removeFilter) {
2274
2437
  if (isUnion(type)) {
2275
- const remainingTypes = type.subtypes.filter((t) => !removeFilter(t));
2276
- if (remainingTypes.length < type.subtypes.length) {
2438
+ const remainingTypes = type.priv.subtypes.filter((t) => !removeFilter(t));
2439
+ if (remainingTypes.length < type.priv.subtypes.length) {
2277
2440
  const newType = combineTypes(remainingTypes);
2278
2441
  if (isUnion(newType)) {
2279
2442
  UnionType.addTypeAliasSource(newType, type);
@@ -2286,7 +2449,7 @@ function removeFromUnion(type, removeFilter) {
2286
2449
  exports.removeFromUnion = removeFromUnion;
2287
2450
  function findSubtype(type, filter) {
2288
2451
  if (isUnion(type)) {
2289
- return type.subtypes.find((subtype) => {
2452
+ return type.priv.subtypes.find((subtype) => {
2290
2453
  return filter(subtype);
2291
2454
  });
2292
2455
  }
@@ -2297,12 +2460,13 @@ exports.findSubtype = findSubtype;
2297
2460
  // the same, only one is returned. If they differ, they
2298
2461
  // are combined into a UnionType. NeverTypes are filtered out.
2299
2462
  // If no types remain in the end, a NeverType is returned.
2300
- function combineTypes(subtypes, maxSubtypeCount) {
2463
+ function combineTypes(subtypes, options) {
2464
+ var _a;
2301
2465
  // Filter out any "Never" and "NoReturn" types.
2302
2466
  let sawNoReturn = false;
2303
2467
  if (subtypes.some((subtype) => subtype.category === 3 /* TypeCategory.Never */))
2304
2468
  subtypes = subtypes.filter((subtype) => {
2305
- if (subtype.category === 3 /* TypeCategory.Never */ && subtype.isNoReturn) {
2469
+ if (subtype.category === 3 /* TypeCategory.Never */ && subtype.priv.isNoReturn) {
2306
2470
  sawNoReturn = true;
2307
2471
  }
2308
2472
  return subtype.category !== 3 /* TypeCategory.Never */;
@@ -2333,12 +2497,12 @@ function combineTypes(subtypes, maxSubtypeCount) {
2333
2497
  if (!expandedTypes) {
2334
2498
  expandedTypes = subtypes.slice(0, i);
2335
2499
  }
2336
- expandedTypes = expandedTypes.concat(subtype.subtypes);
2337
- if (subtype.typeAliasInfo) {
2500
+ expandedTypes = expandedTypes.concat(subtype.priv.subtypes);
2501
+ if ((_a = subtype.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo) {
2338
2502
  typeAliasSources.add(subtype);
2339
2503
  }
2340
- else if (subtype.typeAliasSources) {
2341
- subtype.typeAliasSources.forEach((subtype) => {
2504
+ else if (subtype.priv.typeAliasSources) {
2505
+ subtype.priv.typeAliasSources.forEach((subtype) => {
2342
2506
  typeAliasSources.add(subtype);
2343
2507
  });
2344
2508
  }
@@ -2350,16 +2514,16 @@ function combineTypes(subtypes, maxSubtypeCount) {
2350
2514
  expandedTypes = expandedTypes !== null && expandedTypes !== void 0 ? expandedTypes : subtypes;
2351
2515
  // Sort all of the literal and empty types to the end.
2352
2516
  expandedTypes = expandedTypes.sort((type1, type2) => {
2353
- if (isClass(type1) && type1.literalValue !== undefined) {
2517
+ if (isClass(type1) && type1.priv.literalValue !== undefined) {
2354
2518
  return 1;
2355
2519
  }
2356
- if (isClass(type2) && type2.literalValue !== undefined) {
2520
+ if (isClass(type2) && type2.priv.literalValue !== undefined) {
2357
2521
  return -1;
2358
2522
  }
2359
- if (isClassInstance(type1) && type1.isEmptyContainer) {
2523
+ if (isClassInstance(type1) && type1.priv.isEmptyContainer) {
2360
2524
  return 1;
2361
2525
  }
2362
- else if (isClassInstance(type2) && type2.isEmptyContainer) {
2526
+ else if (isClassInstance(type2) && type2.priv.isEmptyContainer) {
2363
2527
  return -1;
2364
2528
  }
2365
2529
  return 0;
@@ -2371,7 +2535,7 @@ function combineTypes(subtypes, maxSubtypeCount) {
2371
2535
  }
2372
2536
  const newUnionType = UnionType.create();
2373
2537
  if (typeAliasSources.size > 0) {
2374
- newUnionType.typeAliasSources = typeAliasSources;
2538
+ newUnionType.priv.typeAliasSources = typeAliasSources;
2375
2539
  }
2376
2540
  let hitMaxSubtypeCount = false;
2377
2541
  expandedTypes.forEach((subtype, index) => {
@@ -2379,8 +2543,8 @@ function combineTypes(subtypes, maxSubtypeCount) {
2379
2543
  UnionType.addType(newUnionType, subtype);
2380
2544
  }
2381
2545
  else {
2382
- if (maxSubtypeCount === undefined || newUnionType.subtypes.length < maxSubtypeCount) {
2383
- _addTypeIfUnique(newUnionType, subtype);
2546
+ if ((options === null || options === void 0 ? void 0 : options.maxSubtypeCount) === undefined || newUnionType.priv.subtypes.length < options.maxSubtypeCount) {
2547
+ _addTypeIfUnique(newUnionType, subtype, !(options === null || options === void 0 ? void 0 : options.skipElideRedundantLiterals));
2384
2548
  }
2385
2549
  else {
2386
2550
  hitMaxSubtypeCount = true;
@@ -2391,8 +2555,8 @@ function combineTypes(subtypes, maxSubtypeCount) {
2391
2555
  return AnyType.create();
2392
2556
  }
2393
2557
  // 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];
2558
+ if (newUnionType.priv.subtypes.length === 1) {
2559
+ return newUnionType.priv.subtypes[0];
2396
2560
  }
2397
2561
  return newUnionType;
2398
2562
  }
@@ -2405,12 +2569,12 @@ function isSameWithoutLiteralValue(destType, srcType) {
2405
2569
  if (isTypeSame(destType, srcType)) {
2406
2570
  return true;
2407
2571
  }
2408
- if (isInstantiableClass(srcType) && srcType.literalValue !== undefined) {
2572
+ if (isInstantiableClass(srcType) && srcType.priv.literalValue !== undefined) {
2409
2573
  // Strip the literal.
2410
2574
  srcType = ClassType.cloneWithLiteral(srcType, /* value */ undefined);
2411
2575
  return isTypeSame(destType, srcType);
2412
2576
  }
2413
- if (isClassInstance(srcType) && srcType.literalValue !== undefined) {
2577
+ if (isClassInstance(srcType) && srcType.priv.literalValue !== undefined) {
2414
2578
  // Strip the literal.
2415
2579
  srcType = ClassType.cloneWithLiteral(srcType, /* value */ undefined);
2416
2580
  return isTypeSame(destType, srcType, { ignoreConditions: true });
@@ -2418,32 +2582,35 @@ function isSameWithoutLiteralValue(destType, srcType) {
2418
2582
  return false;
2419
2583
  }
2420
2584
  exports.isSameWithoutLiteralValue = isSameWithoutLiteralValue;
2421
- function _addTypeIfUnique(unionType, typeToAdd) {
2585
+ function _addTypeIfUnique(unionType, typeToAdd, elideRedundantLiterals) {
2586
+ var _a, _b, _c;
2422
2587
  // Handle the addition of a string literal in a special manner to
2423
2588
  // avoid n^2 behavior in unions that contain hundreds of string
2424
2589
  // literal types. Skip this for constrained types.
2425
- if (isClass(typeToAdd) && typeToAdd.condition === undefined) {
2426
- const literalMaps = isClassInstance(typeToAdd) ? unionType.literalInstances : unionType.literalClasses;
2590
+ if (isClass(typeToAdd) && !((_a = typeToAdd.props) === null || _a === void 0 ? void 0 : _a.condition)) {
2591
+ const literalMaps = isClassInstance(typeToAdd)
2592
+ ? unionType.priv.literalInstances
2593
+ : unionType.priv.literalClasses;
2427
2594
  if (ClassType.isBuiltIn(typeToAdd, 'str') &&
2428
- typeToAdd.literalValue !== undefined &&
2595
+ typeToAdd.priv.literalValue !== undefined &&
2429
2596
  literalMaps.literalStrMap !== undefined) {
2430
- if (!literalMaps.literalStrMap.has(typeToAdd.literalValue)) {
2597
+ if (!literalMaps.literalStrMap.has(typeToAdd.priv.literalValue)) {
2431
2598
  UnionType.addType(unionType, typeToAdd);
2432
2599
  }
2433
2600
  return;
2434
2601
  }
2435
2602
  else if (ClassType.isBuiltIn(typeToAdd, 'int') &&
2436
- typeToAdd.literalValue !== undefined &&
2603
+ typeToAdd.priv.literalValue !== undefined &&
2437
2604
  literalMaps.literalIntMap !== undefined) {
2438
- if (!literalMaps.literalIntMap.has(typeToAdd.literalValue)) {
2605
+ if (!literalMaps.literalIntMap.has(typeToAdd.priv.literalValue)) {
2439
2606
  UnionType.addType(unionType, typeToAdd);
2440
2607
  }
2441
2608
  return;
2442
2609
  }
2443
2610
  else if (ClassType.isEnumClass(typeToAdd) &&
2444
- typeToAdd.literalValue !== undefined &&
2611
+ typeToAdd.priv.literalValue !== undefined &&
2445
2612
  literalMaps.literalEnumMap !== undefined) {
2446
- const enumLiteral = typeToAdd.literalValue;
2613
+ const enumLiteral = typeToAdd.priv.literalValue;
2447
2614
  if (!literalMaps.literalEnumMap.has(enumLiteral.getName())) {
2448
2615
  UnionType.addType(unionType, typeToAdd);
2449
2616
  }
@@ -2451,8 +2618,8 @@ function _addTypeIfUnique(unionType, typeToAdd) {
2451
2618
  }
2452
2619
  }
2453
2620
  const isPseudoGeneric = isClass(typeToAdd) && ClassType.isPseudoGenericClass(typeToAdd);
2454
- for (let i = 0; i < unionType.subtypes.length; i++) {
2455
- const type = unionType.subtypes[i];
2621
+ for (let i = 0; i < unionType.priv.subtypes.length; i++) {
2622
+ const type = unionType.priv.subtypes[i];
2456
2623
  // Does this type already exist in the types array?
2457
2624
  if (isTypeSame(type, typeToAdd)) {
2458
2625
  return;
@@ -2465,27 +2632,28 @@ function _addTypeIfUnique(unionType, typeToAdd) {
2465
2632
  // parameterized with its own class) ad infinitum.
2466
2633
  if (isPseudoGeneric) {
2467
2634
  if (isTypeSame(type, typeToAdd, { ignorePseudoGeneric: true })) {
2468
- unionType.subtypes[i] = ClassType.cloneForSpecialization(typeToAdd, typeToAdd.details.typeParameters.map(() => UnknownType.create()),
2635
+ unionType.priv.subtypes[i] = ClassType.cloneForSpecialization(typeToAdd, typeToAdd.shared.typeParameters.map(() => UnknownType.create()),
2469
2636
  /* isTypeArgumentExplicit */ true);
2470
2637
  return;
2471
2638
  }
2472
2639
  }
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
2640
  if (isClassInstance(type) && isClassInstance(typeToAdd)) {
2476
- if (isSameWithoutLiteralValue(type, typeToAdd)) {
2477
- if (type.literalValue === undefined) {
2641
+ // If the typeToAdd is a literal value and there's already
2642
+ // a non-literal type that matches, don't add the literal value.
2643
+ if (elideRedundantLiterals && isSameWithoutLiteralValue(type, typeToAdd)) {
2644
+ if (type.priv.literalValue === undefined) {
2478
2645
  return;
2479
2646
  }
2480
2647
  }
2481
2648
  // If we're adding Literal[False] or Literal[True] to its
2482
2649
  // opposite, combine them into a non-literal 'bool' type.
2483
2650
  if (ClassType.isBuiltIn(type, 'bool') &&
2484
- !type.condition &&
2651
+ !((_b = type.props) === null || _b === void 0 ? void 0 : _b.condition) &&
2485
2652
  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);
2653
+ !((_c = typeToAdd.props) === null || _c === void 0 ? void 0 : _c.condition)) {
2654
+ if (typeToAdd.priv.literalValue !== undefined &&
2655
+ !typeToAdd.priv.literalValue === type.priv.literalValue) {
2656
+ unionType.priv.subtypes[i] = ClassType.cloneWithLiteral(type, /* value */ undefined);
2489
2657
  return;
2490
2658
  }
2491
2659
  }
@@ -2493,12 +2661,12 @@ function _addTypeIfUnique(unionType, typeToAdd) {
2493
2661
  // existing type, see if one of them is a proper subset of the other.
2494
2662
  if (ClassType.isTypedDictClass(type) && ClassType.isSameGenericClass(type, typeToAdd)) {
2495
2663
  // Do not proceed if the TypedDicts are generic and have different type arguments.
2496
- if (!type.typeArguments && !typeToAdd.typeArguments) {
2664
+ if (!type.priv.typeArguments && !typeToAdd.priv.typeArguments) {
2497
2665
  if (ClassType.isTypedDictNarrower(typeToAdd, type)) {
2498
2666
  return;
2499
2667
  }
2500
2668
  else if (ClassType.isTypedDictNarrower(type, typeToAdd)) {
2501
- unionType.subtypes[i] = typeToAdd;
2669
+ unionType.priv.subtypes[i] = typeToAdd;
2502
2670
  return;
2503
2671
  }
2504
2672
  }
@@ -2506,7 +2674,7 @@ function _addTypeIfUnique(unionType, typeToAdd) {
2506
2674
  }
2507
2675
  // If the typeToAdd is an empty container and there's already
2508
2676
  // non-empty container of the same type, don't add the empty container.
2509
- if (isClassInstance(typeToAdd) && typeToAdd.isEmptyContainer) {
2677
+ if (isClassInstance(typeToAdd) && typeToAdd.priv.isEmptyContainer) {
2510
2678
  if (isClassInstance(type) && ClassType.isSameGenericClass(type, typeToAdd)) {
2511
2679
  return;
2512
2680
  }