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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/dist/analyzer/analyzerNodeInfo.js +74 -46
  2. package/dist/analyzer/analyzerNodeInfo.js.map +1 -1
  3. package/dist/analyzer/binder.js +507 -513
  4. package/dist/analyzer/binder.js.map +1 -1
  5. package/dist/analyzer/checker.js +652 -633
  6. package/dist/analyzer/checker.js.map +1 -1
  7. package/dist/analyzer/codeFlowEngine.d.ts +5 -3
  8. package/dist/analyzer/codeFlowEngine.js +143 -122
  9. package/dist/analyzer/codeFlowEngine.js.map +1 -1
  10. package/dist/analyzer/codeFlowTypes.js +30 -28
  11. package/dist/analyzer/codeFlowTypes.js.map +1 -1
  12. package/dist/analyzer/constraintSolver.d.ts +1 -1
  13. package/dist/analyzer/constraintSolver.js +71 -67
  14. package/dist/analyzer/constraintSolver.js.map +1 -1
  15. package/dist/analyzer/constructorTransform.js +22 -22
  16. package/dist/analyzer/constructorTransform.js.map +1 -1
  17. package/dist/analyzer/constructors.js +85 -77
  18. package/dist/analyzer/constructors.js.map +1 -1
  19. package/dist/analyzer/dataClasses.js +113 -176
  20. package/dist/analyzer/dataClasses.js.map +1 -1
  21. package/dist/analyzer/declaration.d.ts +1 -1
  22. package/dist/analyzer/declarationUtils.js +14 -15
  23. package/dist/analyzer/declarationUtils.js.map +1 -1
  24. package/dist/analyzer/decorators.js +85 -85
  25. package/dist/analyzer/decorators.js.map +1 -1
  26. package/dist/analyzer/enums.js +71 -57
  27. package/dist/analyzer/enums.js.map +1 -1
  28. package/dist/analyzer/functionTransform.js +8 -18
  29. package/dist/analyzer/functionTransform.js.map +1 -1
  30. package/dist/analyzer/importResolver.d.ts +2 -1
  31. package/dist/analyzer/importResolver.js +40 -29
  32. package/dist/analyzer/importResolver.js.map +1 -1
  33. package/dist/analyzer/importStatementUtils.js +27 -27
  34. package/dist/analyzer/importStatementUtils.js.map +1 -1
  35. package/dist/analyzer/namedTuples.js +33 -59
  36. package/dist/analyzer/namedTuples.js.map +1 -1
  37. package/dist/analyzer/operations.d.ts +4 -4
  38. package/dist/analyzer/operations.js +70 -70
  39. package/dist/analyzer/operations.js.map +1 -1
  40. package/dist/analyzer/packageTypeVerifier.js +66 -62
  41. package/dist/analyzer/packageTypeVerifier.js.map +1 -1
  42. package/dist/analyzer/parameterUtils.d.ts +4 -4
  43. package/dist/analyzer/parameterUtils.js +28 -46
  44. package/dist/analyzer/parameterUtils.js.map +1 -1
  45. package/dist/analyzer/parseTreeUtils.js +268 -269
  46. package/dist/analyzer/parseTreeUtils.js.map +1 -1
  47. package/dist/analyzer/parseTreeWalker.js +76 -76
  48. package/dist/analyzer/parseTreeWalker.js.map +1 -1
  49. package/dist/analyzer/patternMatching.js +195 -147
  50. package/dist/analyzer/patternMatching.js.map +1 -1
  51. package/dist/analyzer/program.js +1 -1
  52. package/dist/analyzer/program.js.map +1 -1
  53. package/dist/analyzer/properties.js +78 -147
  54. package/dist/analyzer/properties.js.map +1 -1
  55. package/dist/analyzer/protocols.js +22 -22
  56. package/dist/analyzer/protocols.js.map +1 -1
  57. package/dist/analyzer/sourceFile.d.ts +3 -2
  58. package/dist/analyzer/sourceFile.js +8 -8
  59. package/dist/analyzer/sourceFile.js.map +1 -1
  60. package/dist/analyzer/sourceMapper.js +20 -19
  61. package/dist/analyzer/sourceMapper.js.map +1 -1
  62. package/dist/analyzer/staticExpressions.js +83 -84
  63. package/dist/analyzer/staticExpressions.js.map +1 -1
  64. package/dist/analyzer/testWalker.js +2 -2
  65. package/dist/analyzer/testWalker.js.map +1 -1
  66. package/dist/analyzer/tracePrinter.js +20 -20
  67. package/dist/analyzer/tracePrinter.js.map +1 -1
  68. package/dist/analyzer/typeDocStringUtils.js +25 -25
  69. package/dist/analyzer/typeDocStringUtils.js.map +1 -1
  70. package/dist/analyzer/typeEvaluator.js +2330 -2367
  71. package/dist/analyzer/typeEvaluator.js.map +1 -1
  72. package/dist/analyzer/typeEvaluatorTypes.d.ts +33 -31
  73. package/dist/analyzer/typeEvaluatorTypes.js +48 -41
  74. package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
  75. package/dist/analyzer/typeGuards.js +221 -217
  76. package/dist/analyzer/typeGuards.js.map +1 -1
  77. package/dist/analyzer/typePrinter.js +118 -115
  78. package/dist/analyzer/typePrinter.js.map +1 -1
  79. package/dist/analyzer/typeStubWriter.js +104 -103
  80. package/dist/analyzer/typeStubWriter.js.map +1 -1
  81. package/dist/analyzer/typeUtils.d.ts +26 -9
  82. package/dist/analyzer/typeUtils.js +460 -404
  83. package/dist/analyzer/typeUtils.js.map +1 -1
  84. package/dist/analyzer/typeVarContext.js +8 -8
  85. package/dist/analyzer/typeVarContext.js.map +1 -1
  86. package/dist/analyzer/typeWalker.js +13 -10
  87. package/dist/analyzer/typeWalker.js.map +1 -1
  88. package/dist/analyzer/typedDicts.js +96 -198
  89. package/dist/analyzer/typedDicts.js.map +1 -1
  90. package/dist/analyzer/types.d.ts +147 -103
  91. package/dist/analyzer/types.js +668 -493
  92. package/dist/analyzer/types.js.map +1 -1
  93. package/dist/commands/dumpFileDebugInfoCommand.js +33 -33
  94. package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
  95. package/dist/common/diagnostic.d.ts +14 -0
  96. package/dist/common/diagnostic.js +41 -1
  97. package/dist/common/diagnostic.js.map +1 -1
  98. package/dist/common/diagnosticSink.d.ts +4 -0
  99. package/dist/common/diagnosticSink.js +21 -1
  100. package/dist/common/diagnosticSink.js.map +1 -1
  101. package/dist/common/fileSystem.d.ts +1 -0
  102. package/dist/common/fileSystem.js.map +1 -1
  103. package/dist/common/fullAccessHost.js +6 -4
  104. package/dist/common/fullAccessHost.js.map +1 -1
  105. package/dist/common/realFileSystem.d.ts +1 -0
  106. package/dist/common/realFileSystem.js +4 -0
  107. package/dist/common/realFileSystem.js.map +1 -1
  108. package/dist/common/textEditTracker.js +14 -14
  109. package/dist/common/textEditTracker.js.map +1 -1
  110. package/dist/languageService/autoImporter.js +10 -10
  111. package/dist/languageService/autoImporter.js.map +1 -1
  112. package/dist/languageService/callHierarchyProvider.js +23 -23
  113. package/dist/languageService/callHierarchyProvider.js.map +1 -1
  114. package/dist/languageService/completionProvider.d.ts +1 -1
  115. package/dist/languageService/completionProvider.js +156 -154
  116. package/dist/languageService/completionProvider.js.map +1 -1
  117. package/dist/languageService/definitionProvider.d.ts +1 -1
  118. package/dist/languageService/definitionProvider.js +3 -1
  119. package/dist/languageService/definitionProvider.js.map +1 -1
  120. package/dist/languageService/documentSymbolCollector.js +19 -19
  121. package/dist/languageService/documentSymbolCollector.js.map +1 -1
  122. package/dist/languageService/hoverProvider.js +25 -24
  123. package/dist/languageService/hoverProvider.js.map +1 -1
  124. package/dist/languageService/importSorter.js +8 -8
  125. package/dist/languageService/importSorter.js.map +1 -1
  126. package/dist/languageService/referencesProvider.js +8 -8
  127. package/dist/languageService/referencesProvider.js.map +1 -1
  128. package/dist/languageService/signatureHelpProvider.d.ts +1 -1
  129. package/dist/languageService/signatureHelpProvider.js +6 -6
  130. package/dist/languageService/signatureHelpProvider.js.map +1 -1
  131. package/dist/languageService/symbolIndexer.js +3 -3
  132. package/dist/languageService/symbolIndexer.js.map +1 -1
  133. package/dist/languageService/tooltipUtils.js +13 -13
  134. package/dist/languageService/tooltipUtils.js.map +1 -1
  135. package/dist/localization/localize.d.ts +3 -0
  136. package/dist/localization/localize.js +1 -0
  137. package/dist/localization/localize.js.map +1 -1
  138. package/dist/localization/package.nls.en-us.json +2 -1
  139. package/dist/parser/parseNodes.d.ts +468 -401
  140. package/dist/parser/parseNodes.js +626 -355
  141. package/dist/parser/parseNodes.js.map +1 -1
  142. package/dist/parser/parser.d.ts +1 -0
  143. package/dist/parser/parser.js +322 -297
  144. package/dist/parser/parser.js.map +1 -1
  145. package/dist/pyright.js +265 -5
  146. package/dist/pyright.js.map +1 -1
  147. package/dist/tests/classDeclaration.test.js +14 -14
  148. package/dist/tests/classDeclaration.test.js.map +1 -1
  149. package/dist/tests/fourslash/hover.init.fourslash.js +1 -1
  150. package/dist/tests/fourslash/hover.init.fourslash.js.map +1 -1
  151. package/dist/tests/harness/vfs/filesystem.d.ts +3 -2
  152. package/dist/tests/harness/vfs/filesystem.js +6 -2
  153. package/dist/tests/harness/vfs/filesystem.js.map +1 -1
  154. package/dist/tests/importResolver.test.js +4 -3
  155. package/dist/tests/importResolver.test.js.map +1 -1
  156. package/dist/tests/parseTreeUtils.test.js +5 -5
  157. package/dist/tests/parseTreeUtils.test.js.map +1 -1
  158. package/dist/tests/parser.test.js +8 -8
  159. package/dist/tests/parser.test.js.map +1 -1
  160. package/dist/tests/sourceMapperUtils.test.js +7 -7
  161. package/dist/tests/sourceMapperUtils.test.js.map +1 -1
  162. package/dist/tests/typeEvaluator2.test.js +2 -2
  163. package/dist/tests/typeEvaluator3.test.js +10 -5
  164. package/dist/tests/typeEvaluator3.test.js.map +1 -1
  165. package/dist/tests/typeEvaluator4.test.js +1 -1
  166. package/dist/tests/typeEvaluator7.test.js +2 -2
  167. package/dist/tests/typeEvaluator7.test.js.map +1 -1
  168. package/dist/tests/typePrinter.test.js +14 -39
  169. package/dist/tests/typePrinter.test.js.map +1 -1
  170. package/package.json +1 -1
@@ -8,9 +8,9 @@
8
8
  * Functions that operate on Type objects.
9
9
  */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.isUnboundedTupleClass = exports.isTupleClass = exports.isMaybeDescriptorInstance = exports.isDescriptorInstance = exports.isCallableType = exports.isProperty = exports.isEllipsisType = exports.getUnionSubtypeCount = exports.getLiteralTypeClassName = exports.containsLiteralType = exports.isLiteralTypeOrUnion = exports.isLiteralType = exports.getSpecializedTupleType = exports.selfSpecializeClass = exports.getUnknownTypeForCallable = exports.getUnknownTypeForParamSpec = exports.getUnknownTypeForTypeVar = exports.specializeWithUnknownTypeArgs = exports.specializeWithDefaultTypeArgs = exports.getTypeVarScopeIds = exports.getTypeVarScopeId = exports.transformPossibleRecursiveTypeAlias = exports.isTypeAliasRecursive = exports.isTypeAliasPlaceholder = exports.getTypeCondition = exports.addConditionToType = exports.getFullNameOfType = exports.derivesFromAnyOrUnknown = exports.isUnionableType = exports.preserveUnknown = exports.areTypesSame = exports.doForEachSignature = exports.allSubtypes = exports.someSubtypes = exports.doForEachSubtype = exports.sortTypes = exports.cleanIncompleteUnknown = exports.mapSignatures = exports.mapSubtypes = exports.makeInferenceContext = exports.isTypeVarSame = exports.isIncompleteUnknown = exports.removeNoneFromUnion = exports.isNoneTypeClass = exports.isNoneInstance = exports.isOptionalType = exports.UniqueSignatureTracker = exports.AssignTypeFlags = exports.ClassIteratorFlags = exports.MemberAccessFlags = void 0;
12
- exports.computeMroLinearization = exports.isVarianceOfTypeArgumentCompatible = exports.combineVariances = exports.requiresSpecialization = exports.requiresTypeArguments = exports.getGeneratorTypeArgs = exports.specializeTupleClass = exports.combineSameSizedTuples = exports.explodeGenericClass = exports.isPartlyUnknown = exports.containsAnyOrUnknown = exports.containsAnyRecursive = exports.getMembersForModule = exports.getMembersForClass = exports.convertToInstantiable = exports.convertToInstance = exports.isEffectivelyInstantiable = exports.isMetaclassInstance = exports.isInstantiableMetaclass = exports.getGeneratorYieldType = exports.getDeclaredGeneratorReturnType = exports.synthesizeTypeVarForSelfCls = exports.derivesFromClassRecursive = exports.derivesFromStdlibClass = exports.specializeForBaseClass = exports.buildTypeVarContext = exports.buildTypeVarContextFromSpecializedClass = exports.setTypeArgumentsRecursive = exports.specializeClassType = exports.getTypeVarArgumentsRecursive = exports.addTypeVarsToListIfUnique = exports.getClassFieldsRecursive = exports.getClassIterator = exports.getClassMemberIterator = exports.lookUpClassMember = exports.lookUpObjectMember = exports.getContainerDepth = exports.getProtocolSymbolsRecursive = exports.getProtocolSymbols = exports.transformExpectedType = exports.replaceTypeVarsWithAny = exports.validateTypeVarDefault = exports.applyInScopePlaceholders = exports.applySourceContextTypeVarsToSignature = exports.applySourceContextTypeVars = exports.applySolvedTypeVars = exports.ensureFunctionSignaturesAreUnique = exports.populateTypeVarContextForSelfType = exports.partiallySpecializeType = exports.isTupleIndexUnambiguous = void 0;
13
- exports.convertParamSpecValueToType = exports.convertTypeToParamSpecValue = exports.getDeclaringModulesForType = void 0;
11
+ exports.isTupleGradualForm = exports.isMaybeDescriptorInstance = exports.isDescriptorInstance = exports.isCallableType = exports.isProperty = exports.isEllipsisType = exports.getUnionSubtypeCount = exports.getLiteralTypeClassName = exports.containsLiteralType = exports.isLiteralTypeOrUnion = exports.isLiteralType = exports.getSpecializedTupleType = exports.selfSpecializeClass = exports.getUnknownTypeForCallable = exports.getUnknownTypeForVariadicTypeVar = exports.getUnknownTypeForParamSpec = exports.getUnknownTypeForTypeVar = exports.specializeWithUnknownTypeArgs = exports.specializeWithDefaultTypeArgs = exports.getTypeVarScopeIds = exports.getTypeVarScopeId = exports.transformPossibleRecursiveTypeAlias = exports.isTypeAliasRecursive = exports.isTypeAliasPlaceholder = exports.getTypeCondition = exports.addConditionToType = exports.getFullNameOfType = exports.derivesFromAnyOrUnknown = exports.isUnionableType = exports.preserveUnknown = exports.areTypesSame = exports.doForEachSignature = exports.allSubtypes = exports.someSubtypes = exports.doForEachSubtype = exports.sortTypes = exports.cleanIncompleteUnknown = exports.mapSignatures = exports.mapSubtypes = exports.makeInferenceContext = exports.isTypeVarSame = exports.isIncompleteUnknown = exports.removeNoneFromUnion = exports.isNoneTypeClass = exports.isNoneInstance = exports.isOptionalType = exports.UniqueSignatureTracker = exports.AssignTypeFlags = exports.ClassIteratorFlags = exports.MemberAccessFlags = void 0;
12
+ exports.combineVariances = exports.requiresSpecialization = exports.requiresTypeArguments = exports.getGeneratorTypeArgs = exports.specializeTupleClass = exports.combineSameSizedTuples = exports.explodeGenericClass = exports.isPartlyUnknown = exports.containsAnyOrUnknown = exports.containsAnyRecursive = exports.getMembersForModule = exports.getMembersForClass = exports.convertToInstantiable = exports.convertToInstance = exports.isEffectivelyInstantiable = exports.isMetaclassInstance = exports.isInstantiableMetaclass = exports.getGeneratorYieldType = exports.getDeclaredGeneratorReturnType = exports.synthesizeTypeVarForSelfCls = exports.derivesFromClassRecursive = exports.derivesFromStdlibClass = exports.specializeForBaseClass = exports.buildTypeVarContext = exports.buildTypeVarContextFromSpecializedClass = exports.setTypeArgumentsRecursive = exports.specializeClassType = exports.getTypeVarArgumentsRecursive = exports.addTypeVarsToListIfUnique = exports.getClassFieldsRecursive = exports.getClassIterator = exports.getClassMemberIterator = exports.lookUpClassMember = exports.lookUpObjectMember = exports.getContainerDepth = exports.getProtocolSymbolsRecursive = exports.getProtocolSymbols = exports.transformExpectedType = exports.replaceTypeVarsWithAny = exports.validateTypeVarDefault = exports.applyInScopePlaceholders = exports.applySourceContextTypeVarsToSignature = exports.applySourceContextTypeVars = exports.applySolvedTypeVars = exports.ensureFunctionSignaturesAreUnique = exports.populateTypeVarContextForSelfType = exports.partiallySpecializeType = exports.isTupleIndexUnambiguous = exports.isUnboundedTupleClass = exports.isTupleClass = void 0;
13
+ exports.convertParamSpecValueToType = exports.convertTypeToParamSpecValue = exports.convertArgumentNodeToFunctionArgument = exports.getDeclaringModulesForType = exports.computeMroLinearization = exports.isVarianceOfTypeArgumentCompatible = void 0;
14
14
  const collectionUtils_1 = require("../common/collectionUtils");
15
15
  const debug_1 = require("../common/debug");
16
16
  const symbol_1 = require("./symbol");
@@ -57,6 +57,10 @@ var MemberAccessFlags;
57
57
  // Report an error if a symbol is an instance variable whose
58
58
  // type is parameterized by a class TypeVar.
59
59
  MemberAccessFlags[MemberAccessFlags["DisallowGenericInstanceVariableAccess"] = 1024] = "DisallowGenericInstanceVariableAccess";
60
+ // The member access should be treated as if it's within a type
61
+ // expression, and errors should be reported if it doesn't conform
62
+ // with type expression rules.
63
+ MemberAccessFlags[MemberAccessFlags["TypeExpression"] = 2048] = "TypeExpression";
60
64
  })(MemberAccessFlags || (exports.MemberAccessFlags = MemberAccessFlags = {}));
61
65
  var ClassIteratorFlags;
62
66
  (function (ClassIteratorFlags) {
@@ -160,8 +164,8 @@ class UniqueSignatureTracker {
160
164
  findSignature(signature) {
161
165
  // Use the associated overload type if this is a function associated with an overload.
162
166
  let effectiveSignature = signature;
163
- if ((0, types_1.isFunction)(signature) && signature.overloaded) {
164
- effectiveSignature = signature.overloaded;
167
+ if ((0, types_1.isFunction)(signature) && signature.priv.overloaded) {
168
+ effectiveSignature = signature.priv.overloaded;
165
169
  }
166
170
  return this._trackedSignatures.find((s) => {
167
171
  return (0, types_1.isTypeSame)(effectiveSignature, s.type);
@@ -170,7 +174,7 @@ class UniqueSignatureTracker {
170
174
  addSignature(signature, offset) {
171
175
  var _a;
172
176
  // If this function is part of a broader overload, use the overload instead.
173
- const effectiveSignature = (0, types_1.isFunction)(signature) ? (_a = signature.overloaded) !== null && _a !== void 0 ? _a : signature : signature;
177
+ const effectiveSignature = (0, types_1.isFunction)(signature) ? (_a = signature.priv.overloaded) !== null && _a !== void 0 ? _a : signature : signature;
174
178
  const existingSignature = this.findSignature(effectiveSignature);
175
179
  if (existingSignature) {
176
180
  if (!existingSignature.expressionOffsets.some((o) => o === offset)) {
@@ -205,7 +209,7 @@ function removeNoneFromUnion(type) {
205
209
  }
206
210
  exports.removeNoneFromUnion = removeNoneFromUnion;
207
211
  function isIncompleteUnknown(type) {
208
- return (0, types_1.isUnknown)(type) && type.isIncomplete;
212
+ return (0, types_1.isUnknown)(type) && type.priv.isIncomplete;
209
213
  }
210
214
  exports.isIncompleteUnknown = isIncompleteUnknown;
211
215
  // Similar to isTypeSame except that type1 is a TypeVar and type2
@@ -216,7 +220,7 @@ function isTypeVarSame(type1, type2) {
216
220
  return true;
217
221
  }
218
222
  // If this isn't a bound TypeVar, return false.
219
- if (type1.details.isParamSpec || type1.details.isVariadic || !type1.details.boundType) {
223
+ if (type1.shared.isParamSpec || type1.shared.isVariadic || !type1.shared.boundType) {
220
224
  return false;
221
225
  }
222
226
  // If the second type isn't a union, return false.
@@ -231,7 +235,7 @@ function isTypeVarSame(type1, type2) {
231
235
  if (!(0, types_1.isTypeSame)(type1, subtype)) {
232
236
  const conditions = getTypeCondition(subtype);
233
237
  if (!conditions ||
234
- !conditions.some((condition) => condition.typeVar.nameWithScope === type1.nameWithScope)) {
238
+ !conditions.some((condition) => condition.typeVar.priv.nameWithScope === type1.priv.nameWithScope)) {
235
239
  isCompatible = false;
236
240
  }
237
241
  }
@@ -249,9 +253,9 @@ exports.makeInferenceContext = makeInferenceContext;
249
253
  // Calls a callback for each subtype and combines the results
250
254
  // into a final type. It performs no memory allocations if the
251
255
  // transformed type is the same as the original.
252
- function mapSubtypes(type, callback, sortSubtypes = false) {
256
+ function mapSubtypes(type, callback, options) {
253
257
  if ((0, types_1.isUnion)(type)) {
254
- const subtypes = sortSubtypes ? sortTypes(type.subtypes) : type.subtypes;
258
+ const subtypes = (options === null || options === void 0 ? void 0 : options.sortSubtypes) ? sortTypes(type.priv.subtypes) : type.priv.subtypes;
255
259
  for (let i = 0; i < subtypes.length; i++) {
256
260
  const subtype = subtypes[i];
257
261
  const transformedType = callback(subtype);
@@ -268,7 +272,9 @@ function mapSubtypes(type, callback, sortSubtypes = false) {
268
272
  for (i++; i < subtypes.length; i++) {
269
273
  accumulateSubtype(callback(subtypes[i]));
270
274
  }
271
- const newType = (0, types_1.combineTypes)(typesToCombine);
275
+ const newType = (0, types_1.combineTypes)(typesToCombine, {
276
+ skipElideRedundantLiterals: options === null || options === void 0 ? void 0 : options.skipElideRedundantLiterals,
277
+ });
272
278
  // Do our best to retain type aliases.
273
279
  if (newType.category === 8 /* TypeCategory.Union */) {
274
280
  types_1.UnionType.addTypeAliasSource(newType, type);
@@ -289,12 +295,12 @@ exports.mapSubtypes = mapSubtypes;
289
295
  // caller to replace one or more signatures with new ones.
290
296
  function mapSignatures(type, callback) {
291
297
  if ((0, types_1.isFunction)(type)) {
292
- return callback(type, 0);
298
+ return callback(type);
293
299
  }
294
300
  const newSignatures = [];
295
301
  let changeMade = false;
296
302
  types_1.OverloadedFunctionType.getOverloads(type).forEach((overload, index) => {
297
- const newOverload = callback(overload, index);
303
+ const newOverload = callback(overload);
298
304
  if (newOverload !== overload) {
299
305
  changeMade = true;
300
306
  }
@@ -308,7 +314,11 @@ function mapSignatures(type, callback) {
308
314
  // Add the unmodified implementation if it's present.
309
315
  const implementation = types_1.OverloadedFunctionType.getImplementation(type);
310
316
  if (implementation) {
311
- newSignatures.push(implementation);
317
+ const newImplementation = callback(implementation);
318
+ if (newImplementation) {
319
+ changeMade = true;
320
+ newSignatures.push(newImplementation);
321
+ }
312
322
  }
313
323
  if (!changeMade) {
314
324
  return type;
@@ -332,13 +342,13 @@ function cleanIncompleteUnknown(type, recursionCount = 0) {
332
342
  recursionCount++;
333
343
  const result = mapSubtypes(type, (subtype) => {
334
344
  // If it's an incomplete unknown, eliminate it.
335
- if ((0, types_1.isUnknown)(subtype) && subtype.isIncomplete) {
345
+ if ((0, types_1.isUnknown)(subtype) && subtype.priv.isIncomplete) {
336
346
  return undefined;
337
347
  }
338
- if ((0, types_1.isClass)(subtype) && subtype.typeArguments) {
348
+ if ((0, types_1.isClass)(subtype) && subtype.priv.typeArguments) {
339
349
  let typeChanged = false;
340
- if (subtype.tupleTypeArguments) {
341
- const updatedTupleTypeArgs = subtype.tupleTypeArguments.map((tupleTypeArg) => {
350
+ if (subtype.priv.tupleTypeArguments) {
351
+ const updatedTupleTypeArgs = subtype.priv.tupleTypeArguments.map((tupleTypeArg) => {
342
352
  const newTypeArg = cleanIncompleteUnknown(tupleTypeArg.type, recursionCount);
343
353
  if (newTypeArg !== tupleTypeArg.type) {
344
354
  typeChanged = true;
@@ -350,11 +360,11 @@ function cleanIncompleteUnknown(type, recursionCount = 0) {
350
360
  };
351
361
  });
352
362
  if (typeChanged) {
353
- return specializeTupleClass(subtype, updatedTupleTypeArgs, !!subtype.isTypeArgumentExplicit, !!subtype.isUnpacked);
363
+ return specializeTupleClass(subtype, updatedTupleTypeArgs, !!subtype.priv.isTypeArgumentExplicit, !!subtype.priv.isUnpacked);
354
364
  }
355
365
  }
356
366
  else {
357
- const updatedTypeArgs = subtype.typeArguments.map((typeArg) => {
367
+ const updatedTypeArgs = subtype.priv.typeArguments.map((typeArg) => {
358
368
  const newTypeArg = cleanIncompleteUnknown(typeArg, recursionCount);
359
369
  if (newTypeArg !== typeArg) {
360
370
  typeChanged = true;
@@ -362,7 +372,7 @@ function cleanIncompleteUnknown(type, recursionCount = 0) {
362
372
  return newTypeArg;
363
373
  });
364
374
  if (typeChanged) {
365
- return types_1.ClassType.cloneForSpecialization(subtype, updatedTypeArgs, !!subtype.isTypeArgumentExplicit);
375
+ return types_1.ClassType.cloneForSpecialization(subtype, updatedTypeArgs, !!subtype.priv.isTypeArgumentExplicit);
366
376
  }
367
377
  }
368
378
  }
@@ -399,14 +409,14 @@ function compareTypes(a, b, recursionCount = 0) {
399
409
  }
400
410
  case 4 /* TypeCategory.Function */: {
401
411
  const bFunc = b;
402
- const aParamCount = a.details.parameters.length;
403
- const bParamCount = bFunc.details.parameters.length;
412
+ const aParamCount = a.shared.parameters.length;
413
+ const bParamCount = bFunc.shared.parameters.length;
404
414
  if (aParamCount !== bParamCount) {
405
415
  return bParamCount - aParamCount;
406
416
  }
407
417
  for (let i = 0; i < aParamCount; i++) {
408
- const aParam = a.details.parameters[i];
409
- const bParam = bFunc.details.parameters[i];
418
+ const aParam = a.shared.parameters[i];
419
+ const bParam = bFunc.shared.parameters[i];
410
420
  if (aParam.category !== bParam.category) {
411
421
  return bParam.category - aParam.category;
412
422
  }
@@ -419,8 +429,8 @@ function compareTypes(a, b, recursionCount = 0) {
419
429
  if (returnTypeComparison !== 0) {
420
430
  return returnTypeComparison;
421
431
  }
422
- const aName = a.details.name;
423
- const bName = bFunc.details.name;
432
+ const aName = a.shared.name;
433
+ const bName = bFunc.shared.name;
424
434
  if (aName < bName) {
425
435
  return -1;
426
436
  }
@@ -431,13 +441,13 @@ function compareTypes(a, b, recursionCount = 0) {
431
441
  }
432
442
  case 5 /* TypeCategory.OverloadedFunction */: {
433
443
  const bOver = b;
434
- const aOverloadCount = a.overloads.length;
435
- const bOverloadCount = bOver.overloads.length;
444
+ const aOverloadCount = a.priv.overloads.length;
445
+ const bOverloadCount = bOver.priv.overloads.length;
436
446
  if (aOverloadCount !== bOverloadCount) {
437
447
  return bOverloadCount - aOverloadCount;
438
448
  }
439
449
  for (let i = 0; i < aOverloadCount; i++) {
440
- const typeComparison = compareTypes(a.overloads[i], bOver.overloads[i]);
450
+ const typeComparison = compareTypes(a.priv.overloads[i], bOver.priv.overloads[i]);
441
451
  if (typeComparison !== 0) {
442
452
  return typeComparison;
443
453
  }
@@ -470,17 +480,17 @@ function compareTypes(a, b, recursionCount = 0) {
470
480
  return -1;
471
481
  }
472
482
  // Sort non-generics before generics.
473
- if (a.details.typeParameters.length > 0 || isTupleClass(a)) {
474
- if (bClass.details.typeParameters.length === 0) {
483
+ if (a.shared.typeParameters.length > 0 || isTupleClass(a)) {
484
+ if (bClass.shared.typeParameters.length === 0) {
475
485
  return 1;
476
486
  }
477
487
  }
478
- else if (bClass.details.typeParameters.length > 0 || isTupleClass(bClass)) {
488
+ else if (bClass.shared.typeParameters.length > 0 || isTupleClass(bClass)) {
479
489
  return -1;
480
490
  }
481
491
  // Sort by class name.
482
- const aName = a.details.name;
483
- const bName = b.details.name;
492
+ const aName = a.shared.name;
493
+ const bName = b.shared.name;
484
494
  if (aName < bName) {
485
495
  return -1;
486
496
  }
@@ -488,8 +498,8 @@ function compareTypes(a, b, recursionCount = 0) {
488
498
  return 1;
489
499
  }
490
500
  // Sort by type argument count.
491
- const aTypeArgCount = a.typeArguments ? a.typeArguments.length : 0;
492
- const bTypeArgCount = bClass.typeArguments ? bClass.typeArguments.length : 0;
501
+ const aTypeArgCount = a.priv.typeArguments ? a.priv.typeArguments.length : 0;
502
+ const bTypeArgCount = bClass.priv.typeArguments ? bClass.priv.typeArguments.length : 0;
493
503
  if (aTypeArgCount < bTypeArgCount) {
494
504
  return -1;
495
505
  }
@@ -498,7 +508,7 @@ function compareTypes(a, b, recursionCount = 0) {
498
508
  }
499
509
  // Sort by type argument.
500
510
  for (let i = 0; i < aTypeArgCount; i++) {
501
- const typeComparison = compareTypes(a.typeArguments[i], bClass.typeArguments[i], recursionCount);
511
+ const typeComparison = compareTypes(a.priv.typeArguments[i], bClass.priv.typeArguments[i], recursionCount);
502
512
  if (typeComparison !== 0) {
503
513
  return typeComparison;
504
514
  }
@@ -506,13 +516,13 @@ function compareTypes(a, b, recursionCount = 0) {
506
516
  return 0;
507
517
  }
508
518
  case 7 /* TypeCategory.Module */: {
509
- const aName = a.moduleName;
510
- const bName = b.moduleName;
519
+ const aName = a.priv.moduleName;
520
+ const bName = b.priv.moduleName;
511
521
  return aName < bName ? -1 : aName === bName ? 0 : 1;
512
522
  }
513
523
  case 9 /* TypeCategory.TypeVar */: {
514
- const aName = a.details.name;
515
- const bName = b.details.name;
524
+ const aName = a.shared.name;
525
+ const bName = b.shared.name;
516
526
  return aName < bName ? -1 : aName === bName ? 0 : 1;
517
527
  }
518
528
  }
@@ -520,7 +530,7 @@ function compareTypes(a, b, recursionCount = 0) {
520
530
  }
521
531
  function doForEachSubtype(type, callback, sortSubtypes = false) {
522
532
  if ((0, types_1.isUnion)(type)) {
523
- const subtypes = sortSubtypes ? sortTypes(type.subtypes) : type.subtypes;
533
+ const subtypes = sortSubtypes ? sortTypes(type.priv.subtypes) : type.priv.subtypes;
524
534
  subtypes.forEach((subtype, index) => {
525
535
  callback(subtype, index, subtypes);
526
536
  });
@@ -532,7 +542,7 @@ function doForEachSubtype(type, callback, sortSubtypes = false) {
532
542
  exports.doForEachSubtype = doForEachSubtype;
533
543
  function someSubtypes(type, callback) {
534
544
  if ((0, types_1.isUnion)(type)) {
535
- return type.subtypes.some((subtype) => {
545
+ return type.priv.subtypes.some((subtype) => {
536
546
  return callback(subtype);
537
547
  });
538
548
  }
@@ -543,7 +553,7 @@ function someSubtypes(type, callback) {
543
553
  exports.someSubtypes = someSubtypes;
544
554
  function allSubtypes(type, callback) {
545
555
  if ((0, types_1.isUnion)(type)) {
546
- return type.subtypes.every((subtype) => {
556
+ return type.priv.subtypes.every((subtype) => {
547
557
  callback(subtype);
548
558
  });
549
559
  }
@@ -580,10 +590,10 @@ exports.areTypesSame = areTypesSame;
580
590
  // the incomplete flag on the unknown if present. The caller should verify that
581
591
  // one or the other type is Unknown or Any.
582
592
  function preserveUnknown(type1, type2) {
583
- if ((0, types_1.isUnknown)(type1) && type1.isIncomplete) {
593
+ if ((0, types_1.isUnknown)(type1) && type1.priv.isIncomplete) {
584
594
  return type1;
585
595
  }
586
- else if ((0, types_1.isUnknown)(type2) && type2.isIncomplete) {
596
+ else if ((0, types_1.isUnknown)(type2) && type2.priv.isIncomplete) {
587
597
  return type2;
588
598
  }
589
599
  else if ((0, types_1.isUnknown)(type1) || (0, types_1.isUnknown)(type2)) {
@@ -629,32 +639,33 @@ function derivesFromAnyOrUnknown(type) {
629
639
  }
630
640
  exports.derivesFromAnyOrUnknown = derivesFromAnyOrUnknown;
631
641
  function getFullNameOfType(type) {
632
- var _a;
633
- if ((_a = type.typeAliasInfo) === null || _a === void 0 ? void 0 : _a.fullName) {
634
- return type.typeAliasInfo.fullName;
642
+ var _a, _b;
643
+ if ((_b = (_a = type.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo) === null || _b === void 0 ? void 0 : _b.fullName) {
644
+ return type.props.typeAliasInfo.fullName;
635
645
  }
636
646
  switch (type.category) {
637
647
  case 2 /* TypeCategory.Any */:
638
648
  case 1 /* TypeCategory.Unknown */:
639
649
  return 'typing.Any';
640
650
  case 6 /* TypeCategory.Class */:
641
- return type.details.fullName;
651
+ return type.shared.fullName;
642
652
  case 4 /* TypeCategory.Function */:
643
- return type.details.fullName;
653
+ return type.shared.fullName;
644
654
  case 7 /* TypeCategory.Module */:
645
- return type.moduleName;
655
+ return type.priv.moduleName;
646
656
  case 5 /* TypeCategory.OverloadedFunction */:
647
- return type.overloads[0].details.fullName;
657
+ return type.priv.overloads[0].shared.fullName;
648
658
  }
649
659
  return undefined;
650
660
  }
651
661
  exports.getFullNameOfType = getFullNameOfType;
652
662
  function addConditionToType(type, condition, skipSelfCondition = false) {
663
+ var _a, _b;
653
664
  if (!condition) {
654
665
  return type;
655
666
  }
656
667
  if (skipSelfCondition) {
657
- condition = condition.filter((c) => !c.typeVar.details.isSynthesizedSelf);
668
+ condition = condition.filter((c) => !c.typeVar.shared.isSynthesizedSelf);
658
669
  if (condition.length === 0) {
659
670
  return type;
660
671
  }
@@ -668,17 +679,18 @@ function addConditionToType(type, condition, skipSelfCondition = false) {
668
679
  case 9 /* TypeCategory.TypeVar */:
669
680
  return type;
670
681
  case 4 /* TypeCategory.Function */:
671
- return types_1.TypeBase.cloneForCondition(type, types_1.TypeCondition.combine(type.condition, condition));
682
+ return types_1.TypeBase.cloneForCondition(type, types_1.TypeCondition.combine((_a = type.props) === null || _a === void 0 ? void 0 : _a.condition, condition));
672
683
  case 5 /* TypeCategory.OverloadedFunction */:
673
- return types_1.OverloadedFunctionType.create(type.overloads.map((t) => addConditionToType(t, condition)));
684
+ return types_1.OverloadedFunctionType.create(type.priv.overloads.map((t) => addConditionToType(t, condition)));
674
685
  case 6 /* TypeCategory.Class */:
675
- return types_1.TypeBase.cloneForCondition(type, types_1.TypeCondition.combine(type.condition, condition));
686
+ return types_1.TypeBase.cloneForCondition(type, types_1.TypeCondition.combine((_b = type.props) === null || _b === void 0 ? void 0 : _b.condition, condition));
676
687
  case 8 /* TypeCategory.Union */:
677
- return (0, types_1.combineTypes)(type.subtypes.map((t) => addConditionToType(t, condition)));
688
+ return (0, types_1.combineTypes)(type.priv.subtypes.map((t) => addConditionToType(t, condition)));
678
689
  }
679
690
  }
680
691
  exports.addConditionToType = addConditionToType;
681
692
  function getTypeCondition(type) {
693
+ var _a;
682
694
  switch (type.category) {
683
695
  case 0 /* TypeCategory.Unbound */:
684
696
  case 1 /* TypeCategory.Unknown */:
@@ -691,7 +703,7 @@ function getTypeCondition(type) {
691
703
  return undefined;
692
704
  case 6 /* TypeCategory.Class */:
693
705
  case 4 /* TypeCategory.Function */:
694
- return type.condition;
706
+ return (_a = type.props) === null || _a === void 0 ? void 0 : _a.condition;
695
707
  }
696
708
  }
697
709
  exports.getTypeCondition = getTypeCondition;
@@ -705,6 +717,7 @@ exports.isTypeAliasPlaceholder = isTypeAliasPlaceholder;
705
717
  // within the specified type. It's OK if it's used indirectly as
706
718
  // a type argument.
707
719
  function isTypeAliasRecursive(typeAliasPlaceholder, type) {
720
+ var _a, _b;
708
721
  if (type.category !== 8 /* TypeCategory.Union */) {
709
722
  if (type === typeAliasPlaceholder) {
710
723
  return true;
@@ -712,31 +725,32 @@ function isTypeAliasRecursive(typeAliasPlaceholder, type) {
712
725
  // Handle the specific case where the type alias directly refers to itself.
713
726
  // In this case, the type will be unbound because it could not be resolved.
714
727
  return ((0, types_1.isUnbound)(type) &&
715
- type.typeAliasInfo &&
716
- type.typeAliasInfo.name === typeAliasPlaceholder.details.recursiveTypeAliasName);
728
+ ((_a = type.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo) &&
729
+ type.props.typeAliasInfo.name === ((_b = typeAliasPlaceholder.shared.recursiveAlias) === null || _b === void 0 ? void 0 : _b.name));
717
730
  }
718
- return ((0, types_1.findSubtype)(type, (subtype) => (0, types_1.isTypeVar)(subtype) && subtype.details === typeAliasPlaceholder.details) !==
731
+ return ((0, types_1.findSubtype)(type, (subtype) => (0, types_1.isTypeVar)(subtype) && subtype.shared === typeAliasPlaceholder.shared) !==
719
732
  undefined);
720
733
  }
721
734
  exports.isTypeAliasRecursive = isTypeAliasRecursive;
722
735
  function transformPossibleRecursiveTypeAlias(type) {
723
- var _a;
736
+ var _a, _b;
724
737
  if (type) {
725
- if ((0, types_1.isTypeVar)(type) && type.details.recursiveTypeAliasName && type.details.boundType) {
738
+ const aliasInfo = (_a = type.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo;
739
+ if ((0, types_1.isTypeVar)(type) && ((_b = type.shared.recursiveAlias) === null || _b === void 0 ? void 0 : _b.name) && type.shared.boundType) {
726
740
  const unspecializedType = types_1.TypeBase.isInstance(type)
727
- ? convertToInstance(type.details.boundType)
728
- : type.details.boundType;
729
- if (!((_a = type.typeAliasInfo) === null || _a === void 0 ? void 0 : _a.typeArguments) || !type.details.recursiveTypeParameters) {
741
+ ? convertToInstance(type.shared.boundType)
742
+ : type.shared.boundType;
743
+ if (!(aliasInfo === null || aliasInfo === void 0 ? void 0 : aliasInfo.typeArguments) || !type.shared.recursiveAlias.typeParameters) {
730
744
  return unspecializedType;
731
745
  }
732
- const typeVarContext = buildTypeVarContext(type.details.recursiveTypeParameters, type.typeAliasInfo.typeArguments, getTypeVarScopeId(type));
746
+ const typeVarContext = buildTypeVarContext(type.shared.recursiveAlias.typeParameters, aliasInfo.typeArguments, getTypeVarScopeId(type));
733
747
  return applySolvedTypeVars(unspecializedType, typeVarContext);
734
748
  }
735
- if ((0, types_1.isUnion)(type) && type.includesRecursiveTypeAlias) {
749
+ if ((0, types_1.isUnion)(type) && type.priv.includesRecursiveTypeAlias) {
736
750
  let newType = mapSubtypes(type, (subtype) => transformPossibleRecursiveTypeAlias(subtype));
737
- if (newType !== type && type.typeAliasInfo) {
751
+ if (newType !== type && aliasInfo) {
738
752
  // Copy the type alias information if present.
739
- newType = types_1.TypeBase.cloneForTypeAlias(newType, type.typeAliasInfo.name, type.typeAliasInfo.fullName, type.typeAliasInfo.moduleName, type.typeAliasInfo.fileUri, type.typeAliasInfo.typeVarScopeId, type.typeAliasInfo.isPep695Syntax, type.typeAliasInfo.typeParameters, type.typeAliasInfo.typeArguments);
753
+ newType = types_1.TypeBase.cloneForTypeAlias(newType, aliasInfo.name, aliasInfo.fullName, aliasInfo.moduleName, aliasInfo.fileUri, aliasInfo.typeVarScopeId, aliasInfo.isPep695Syntax, aliasInfo.typeParameters, aliasInfo.typeArguments);
740
754
  }
741
755
  return newType;
742
756
  }
@@ -746,13 +760,13 @@ function transformPossibleRecursiveTypeAlias(type) {
746
760
  exports.transformPossibleRecursiveTypeAlias = transformPossibleRecursiveTypeAlias;
747
761
  function getTypeVarScopeId(type) {
748
762
  if ((0, types_1.isClass)(type)) {
749
- return type.details.typeVarScopeId;
763
+ return type.shared.typeVarScopeId;
750
764
  }
751
765
  if ((0, types_1.isFunction)(type)) {
752
- return type.details.typeVarScopeId;
766
+ return type.shared.typeVarScopeId;
753
767
  }
754
768
  if ((0, types_1.isTypeVar)(type)) {
755
- return type.scopeId;
769
+ return type.priv.scopeId;
756
770
  }
757
771
  return undefined;
758
772
  }
@@ -766,14 +780,11 @@ function getTypeVarScopeIds(type) {
766
780
  scopeIds.push(scopeId);
767
781
  }
768
782
  if ((0, types_1.isFunction)(type)) {
769
- if (type.details.constructorTypeVarScopeId) {
770
- scopeIds.push(type.details.constructorTypeVarScopeId);
771
- }
772
- if (type.details.higherOrderTypeVarScopeIds) {
773
- scopeIds.push(...type.details.higherOrderTypeVarScopeIds);
783
+ if (type.priv.constructorTypeVarScopeId) {
784
+ scopeIds.push(type.priv.constructorTypeVarScopeId);
774
785
  }
775
- if (type.boundTypeVarScopeId) {
776
- scopeIds.push(type.boundTypeVarScopeId);
786
+ if (type.priv.higherOrderTypeVarScopeIds) {
787
+ scopeIds.push(...type.priv.higherOrderTypeVarScopeIds);
777
788
  }
778
789
  }
779
790
  return scopeIds;
@@ -783,34 +794,37 @@ exports.getTypeVarScopeIds = getTypeVarScopeIds;
783
794
  // specified, specialize it with default type arguments (Unknown or the
784
795
  // default type if provided).
785
796
  function specializeWithDefaultTypeArgs(type) {
786
- if (type.details.typeParameters.length === 0 || type.typeArguments) {
797
+ if (type.shared.typeParameters.length === 0 || type.priv.typeArguments) {
787
798
  return type;
788
799
  }
789
- return types_1.ClassType.cloneForSpecialization(type, type.details.typeParameters.map((param) => param.details.defaultType),
800
+ return types_1.ClassType.cloneForSpecialization(type, type.shared.typeParameters.map((param) => param.shared.defaultType),
790
801
  /* isTypeArgumentExplicit */ false,
791
- /* includeSubclasses */ type.includeSubclasses);
802
+ /* includeSubclasses */ type.priv.includeSubclasses);
792
803
  }
793
804
  exports.specializeWithDefaultTypeArgs = specializeWithDefaultTypeArgs;
794
805
  // Specializes the class with "Unknown" type args (or the equivalent for ParamSpecs
795
806
  // or TypeVarTuples).
796
- function specializeWithUnknownTypeArgs(type) {
797
- if (type.details.typeParameters.length === 0) {
807
+ function specializeWithUnknownTypeArgs(type, tupleClassType) {
808
+ if (type.shared.typeParameters.length === 0) {
798
809
  return type;
799
810
  }
800
811
  if (isTupleClass(type)) {
801
812
  return types_1.ClassType.cloneIncludeSubclasses(specializeTupleClass(type, [{ type: types_1.UnknownType.create(), isUnbounded: true }],
802
- /* isTypeArgumentExplicit */ false), !!type.includeSubclasses);
813
+ /* isTypeArgumentExplicit */ false), !!type.priv.includeSubclasses);
803
814
  }
804
- return types_1.ClassType.cloneForSpecialization(type, type.details.typeParameters.map((param) => getUnknownTypeForTypeVar(param)),
815
+ return types_1.ClassType.cloneForSpecialization(type, type.shared.typeParameters.map((param) => getUnknownTypeForTypeVar(param, tupleClassType)),
805
816
  /* isTypeArgumentExplicit */ false,
806
- /* includeSubclasses */ type.includeSubclasses);
817
+ /* includeSubclasses */ type.priv.includeSubclasses);
807
818
  }
808
819
  exports.specializeWithUnknownTypeArgs = specializeWithUnknownTypeArgs;
809
820
  // Returns "Unknown" for simple TypeVars or the equivalent for a ParamSpec.
810
- function getUnknownTypeForTypeVar(typeVar) {
811
- if (typeVar.details.isParamSpec) {
821
+ function getUnknownTypeForTypeVar(typeVar, tupleClassType) {
822
+ if (typeVar.shared.isParamSpec) {
812
823
  return getUnknownTypeForParamSpec();
813
824
  }
825
+ if (typeVar.shared.isVariadic && tupleClassType) {
826
+ return getUnknownTypeForVariadicTypeVar(tupleClassType);
827
+ }
814
828
  return types_1.UnknownType.create();
815
829
  }
816
830
  exports.getUnknownTypeForTypeVar = getUnknownTypeForTypeVar;
@@ -821,25 +835,33 @@ function getUnknownTypeForParamSpec() {
821
835
  return newFunction;
822
836
  }
823
837
  exports.getUnknownTypeForParamSpec = getUnknownTypeForParamSpec;
838
+ function getUnknownTypeForVariadicTypeVar(tupleClassType) {
839
+ (0, debug_1.assert)((0, types_1.isInstantiableClass)(tupleClassType) && types_1.ClassType.isBuiltIn(tupleClassType, 'tuple'));
840
+ return types_1.ClassType.cloneAsInstance(specializeTupleClass(tupleClassType, [{ type: types_1.UnknownType.create(), isUnbounded: true }],
841
+ /* isTypeArgumentExplicit */ true,
842
+ /* isUnpackedTuple */ true));
843
+ }
844
+ exports.getUnknownTypeForVariadicTypeVar = getUnknownTypeForVariadicTypeVar;
824
845
  // Returns the equivalent of "Callable[..., Unknown]".
825
846
  function getUnknownTypeForCallable() {
826
847
  const newFunction = types_1.FunctionType.createSynthesizedInstance('', 32768 /* FunctionTypeFlags.GradualCallableForm */);
827
848
  types_1.FunctionType.addDefaultParameters(newFunction);
828
- newFunction.details.declaredReturnType = types_1.UnknownType.create();
849
+ newFunction.shared.declaredReturnType = types_1.UnknownType.create();
829
850
  return newFunction;
830
851
  }
831
852
  exports.getUnknownTypeForCallable = getUnknownTypeForCallable;
832
853
  // If the class is generic and not already specialized, this function
833
854
  // "self specializes" the class, filling in its own type parameters
834
855
  // as type arguments.
835
- function selfSpecializeClass(type, overrideTypeArgs = false) {
836
- if (type.details.typeParameters.length === 0) {
856
+ function selfSpecializeClass(type, options) {
857
+ if (type.shared.typeParameters.length === 0) {
837
858
  return type;
838
859
  }
839
- if (type.typeArguments && !overrideTypeArgs) {
860
+ if (type.priv.typeArguments && !(options === null || options === void 0 ? void 0 : options.overrideTypeArgs)) {
840
861
  return type;
841
862
  }
842
- return types_1.ClassType.cloneForSpecialization(type, type.details.typeParameters, /* isTypeArgumentExplicit */ true);
863
+ const typeParams = type.shared.typeParameters;
864
+ return types_1.ClassType.cloneForSpecialization(type, typeParams, /* isTypeArgumentExplicit */ true);
843
865
  }
844
866
  exports.selfSpecializeClass = selfSpecializeClass;
845
867
  // Determines whether the type derives from tuple. If so, it returns
@@ -857,7 +879,7 @@ function getSpecializedTupleType(type) {
857
879
  }
858
880
  // See if this class derives from Tuple or tuple. If it does, we'll assume that it
859
881
  // hasn't been overridden in a way that changes the behavior of the tuple class.
860
- const tupleClass = classType.details.mro.find((mroClass) => (0, types_1.isInstantiableClass)(mroClass) && isTupleClass(mroClass));
882
+ const tupleClass = classType.shared.mro.find((mroClass) => (0, types_1.isInstantiableClass)(mroClass) && isTupleClass(mroClass));
861
883
  if (!tupleClass || !(0, types_1.isInstantiableClass)(tupleClass)) {
862
884
  return undefined;
863
885
  }
@@ -869,7 +891,7 @@ function getSpecializedTupleType(type) {
869
891
  }
870
892
  exports.getSpecializedTupleType = getSpecializedTupleType;
871
893
  function isLiteralType(type) {
872
- return types_1.TypeBase.isInstance(type) && type.literalValue !== undefined;
894
+ return types_1.TypeBase.isInstance(type) && type.priv.literalValue !== undefined;
873
895
  }
874
896
  exports.isLiteralType = isLiteralType;
875
897
  function isLiteralTypeOrUnion(type, allowNone = false) {
@@ -877,7 +899,7 @@ function isLiteralTypeOrUnion(type, allowNone = false) {
877
899
  if (allowNone && isNoneInstance(type)) {
878
900
  return true;
879
901
  }
880
- return type.literalValue !== undefined;
902
+ return type.priv.literalValue !== undefined;
881
903
  }
882
904
  if ((0, types_1.isUnion)(type)) {
883
905
  return !(0, types_1.findSubtype)(type, (subtype) => {
@@ -887,7 +909,7 @@ function isLiteralTypeOrUnion(type, allowNone = false) {
887
909
  if (isNoneInstance(subtype)) {
888
910
  return !allowNone;
889
911
  }
890
- return subtype.literalValue === undefined;
912
+ return subtype.priv.literalValue === undefined;
891
913
  });
892
914
  }
893
915
  return false;
@@ -923,8 +945,8 @@ exports.containsLiteralType = containsLiteralType;
923
945
  // it returns undefined.
924
946
  function getLiteralTypeClassName(type) {
925
947
  if ((0, types_1.isClassInstance)(type)) {
926
- if (type.literalValue !== undefined && types_1.ClassType.isBuiltIn(type)) {
927
- return type.details.name;
948
+ if (type.priv.literalValue !== undefined && types_1.ClassType.isBuiltIn(type)) {
949
+ return type.shared.name;
928
950
  }
929
951
  return undefined;
930
952
  }
@@ -947,13 +969,13 @@ function getLiteralTypeClassName(type) {
947
969
  exports.getLiteralTypeClassName = getLiteralTypeClassName;
948
970
  function getUnionSubtypeCount(type) {
949
971
  if ((0, types_1.isUnion)(type)) {
950
- return type.subtypes.length;
972
+ return type.priv.subtypes.length;
951
973
  }
952
974
  return 1;
953
975
  }
954
976
  exports.getUnionSubtypeCount = getUnionSubtypeCount;
955
977
  function isEllipsisType(type) {
956
- return (0, types_1.isAny)(type) && type.isEllipsis;
978
+ return (0, types_1.isAny)(type) && type.priv.isEllipsis;
957
979
  }
958
980
  exports.isEllipsisType = isEllipsisType;
959
981
  function isProperty(type) {
@@ -975,21 +997,21 @@ function isCallableType(type) {
975
997
  return !!callMember;
976
998
  }
977
999
  if ((0, types_1.isUnion)(type)) {
978
- return type.subtypes.every((subtype) => isCallableType(subtype));
1000
+ return type.priv.subtypes.every((subtype) => isCallableType(subtype));
979
1001
  }
980
1002
  return false;
981
1003
  }
982
1004
  exports.isCallableType = isCallableType;
983
1005
  function isDescriptorInstance(type, requireSetter = false) {
984
1006
  if ((0, types_1.isUnion)(type)) {
985
- return type.subtypes.every((subtype) => isMaybeDescriptorInstance(subtype, requireSetter));
1007
+ return type.priv.subtypes.every((subtype) => isMaybeDescriptorInstance(subtype, requireSetter));
986
1008
  }
987
1009
  return isMaybeDescriptorInstance(type, requireSetter);
988
1010
  }
989
1011
  exports.isDescriptorInstance = isDescriptorInstance;
990
1012
  function isMaybeDescriptorInstance(type, requireSetter = false) {
991
1013
  if ((0, types_1.isUnion)(type)) {
992
- return type.subtypes.some((subtype) => isMaybeDescriptorInstance(subtype, requireSetter));
1014
+ return type.priv.subtypes.some((subtype) => isMaybeDescriptorInstance(subtype, requireSetter));
993
1015
  }
994
1016
  if (!(0, types_1.isClassInstance)(type)) {
995
1017
  return false;
@@ -1003,6 +1025,15 @@ function isMaybeDescriptorInstance(type, requireSetter = false) {
1003
1025
  return true;
1004
1026
  }
1005
1027
  exports.isMaybeDescriptorInstance = isMaybeDescriptorInstance;
1028
+ function isTupleGradualForm(type) {
1029
+ return ((0, types_1.isClassInstance)(type) &&
1030
+ isTupleClass(type) &&
1031
+ type.priv.tupleTypeArguments &&
1032
+ type.priv.tupleTypeArguments.length === 1 &&
1033
+ (0, types_1.isAnyOrUnknown)(type.priv.tupleTypeArguments[0].type) &&
1034
+ type.priv.tupleTypeArguments[0].isUnbounded);
1035
+ }
1036
+ exports.isTupleGradualForm = isTupleGradualForm;
1006
1037
  function isTupleClass(type) {
1007
1038
  return types_1.ClassType.isBuiltIn(type, 'tuple');
1008
1039
  }
@@ -1011,24 +1042,24 @@ exports.isTupleClass = isTupleClass;
1011
1042
  // the form tuple[x, ...] where the number of elements
1012
1043
  // in the tuple is unknown.
1013
1044
  function isUnboundedTupleClass(type) {
1014
- return (type.tupleTypeArguments &&
1015
- type.tupleTypeArguments.some((t) => t.isUnbounded || (0, types_1.isUnpackedVariadicTypeVar)(t.type)));
1045
+ return (type.priv.tupleTypeArguments &&
1046
+ type.priv.tupleTypeArguments.some((t) => t.isUnbounded || (0, types_1.isUnpackedVariadicTypeVar)(t.type)));
1016
1047
  }
1017
1048
  exports.isUnboundedTupleClass = isUnboundedTupleClass;
1018
1049
  // Indicates whether the specified index is within range and its type is unambiguous
1019
1050
  // in that it doesn't involve any element ranges that are of indeterminate length.
1020
1051
  function isTupleIndexUnambiguous(type, index) {
1021
- if (!type.tupleTypeArguments) {
1052
+ if (!type.priv.tupleTypeArguments) {
1022
1053
  return false;
1023
1054
  }
1024
1055
  if (index < 0) {
1025
- if (isUnboundedTupleClass(type) || type.tupleTypeArguments.length + index < 0) {
1056
+ if (isUnboundedTupleClass(type) || type.priv.tupleTypeArguments.length + index < 0) {
1026
1057
  return false;
1027
1058
  }
1028
1059
  }
1029
- let unambiguousIndexLimit = type.tupleTypeArguments.findIndex((t) => t.isUnbounded || (0, types_1.isUnpackedVariadicTypeVar)(t.type));
1060
+ let unambiguousIndexLimit = type.priv.tupleTypeArguments.findIndex((t) => t.isUnbounded || (0, types_1.isUnpackedVariadicTypeVar)(t.type));
1030
1061
  if (unambiguousIndexLimit < 0) {
1031
- unambiguousIndexLimit = type.tupleTypeArguments.length;
1062
+ unambiguousIndexLimit = type.priv.tupleTypeArguments.length;
1032
1063
  }
1033
1064
  return index < unambiguousIndexLimit;
1034
1065
  }
@@ -1051,7 +1082,7 @@ function partiallySpecializeType(type, contextClassType, selfClass, typeClassTyp
1051
1082
  // If this is a property, we may need to partially specialize the
1052
1083
  // access methods associated with it.
1053
1084
  if ((0, types_1.isClass)(result)) {
1054
- if (result.fgetInfo || result.fsetInfo || result.fdelInfo) {
1085
+ if (result.priv.fgetInfo || result.priv.fsetInfo || result.priv.fdelInfo) {
1055
1086
  function updatePropertyMethodInfo(methodInfo) {
1056
1087
  if (!methodInfo) {
1057
1088
  return undefined;
@@ -1062,9 +1093,9 @@ function partiallySpecializeType(type, contextClassType, selfClass, typeClassTyp
1062
1093
  };
1063
1094
  }
1064
1095
  result = types_1.TypeBase.cloneType(result);
1065
- result.fgetInfo = updatePropertyMethodInfo(result.fgetInfo);
1066
- result.fsetInfo = updatePropertyMethodInfo(result.fsetInfo);
1067
- result.fdelInfo = updatePropertyMethodInfo(result.fdelInfo);
1096
+ result.priv.fgetInfo = updatePropertyMethodInfo(result.priv.fgetInfo);
1097
+ result.priv.fsetInfo = updatePropertyMethodInfo(result.priv.fsetInfo);
1098
+ result.priv.fdelInfo = updatePropertyMethodInfo(result.priv.fdelInfo);
1068
1099
  }
1069
1100
  }
1070
1101
  return result;
@@ -1077,7 +1108,7 @@ function populateTypeVarContextForSelfType(typeVarContext, contextClassType, sel
1077
1108
  // Instead, we'll do a simplified version of it here.
1078
1109
  const selfWithoutLiteral = mapSubtypes(selfInstance, (subtype) => {
1079
1110
  if ((0, types_1.isClass)(subtype)) {
1080
- if (subtype.literalValue !== undefined) {
1111
+ if (subtype.priv.literalValue !== undefined) {
1081
1112
  return types_1.ClassType.cloneWithLiteral(subtype, /* value */ undefined);
1082
1113
  }
1083
1114
  }
@@ -1149,7 +1180,7 @@ function applyInScopePlaceholders(typeVarContext) {
1149
1180
  typeVarContext.doForEachSignatureContext((signature) => {
1150
1181
  signature.getTypeVars().forEach((entry) => {
1151
1182
  const typeVar = entry.typeVar;
1152
- if (!typeVar.isInScopePlaceholder) {
1183
+ if (!typeVar.priv.isInScopePlaceholder) {
1153
1184
  const newNarrowTypeBound = entry.narrowBound
1154
1185
  ? applyInScopePlaceholdersToType(entry.narrowBound, signature)
1155
1186
  : undefined;
@@ -1179,9 +1210,9 @@ exports.applyInScopePlaceholders = applyInScopePlaceholders;
1179
1210
  function validateTypeVarDefault(typeVar, liveTypeParams, invalidTypeVars) {
1180
1211
  // If there is no default type or the default type is concrete, there's
1181
1212
  // no need to do any more work here.
1182
- if (typeVar.details.isDefaultExplicit && requiresSpecialization(typeVar.details.defaultType)) {
1213
+ if (typeVar.shared.isDefaultExplicit && requiresSpecialization(typeVar.shared.defaultType)) {
1183
1214
  const validator = new TypeVarDefaultValidator(liveTypeParams, invalidTypeVars);
1184
- validator.apply(typeVar.details.defaultType, 0);
1215
+ validator.apply(typeVar.shared.defaultType, 0);
1185
1216
  }
1186
1217
  }
1187
1218
  exports.validateTypeVarDefault = validateTypeVarDefault;
@@ -1206,7 +1237,7 @@ exports.transformExpectedType = transformExpectedType;
1206
1237
  // appears in a parent and a child, the child overrides the parent.
1207
1238
  function getProtocolSymbols(classType) {
1208
1239
  const symbolMap = new Map();
1209
- if ((classType.details.flags & 512 /* ClassTypeFlags.ProtocolClass */) !== 0) {
1240
+ if ((classType.shared.flags & 512 /* ClassTypeFlags.ProtocolClass */) !== 0) {
1210
1241
  getProtocolSymbolsRecursive(classType, symbolMap, 512 /* ClassTypeFlags.ProtocolClass */);
1211
1242
  }
1212
1243
  return symbolMap;
@@ -1216,8 +1247,8 @@ function getProtocolSymbolsRecursive(classType, symbolMap, classFlags = 512 /* C
1216
1247
  if (recursionCount > types_1.maxTypeRecursionCount) {
1217
1248
  return;
1218
1249
  }
1219
- classType.details.baseClasses.forEach((baseClass) => {
1220
- if ((0, types_1.isClass)(baseClass) && (baseClass.details.flags & classFlags) !== 0) {
1250
+ classType.shared.baseClasses.forEach((baseClass) => {
1251
+ if ((0, types_1.isClass)(baseClass) && (baseClass.shared.flags & classFlags) !== 0) {
1221
1252
  getProtocolSymbolsRecursive(baseClass, symbolMap, classFlags, recursionCount + 1);
1222
1253
  }
1223
1254
  });
@@ -1248,16 +1279,16 @@ function getContainerDepth(type, recursionCount = 0) {
1248
1279
  return 0;
1249
1280
  }
1250
1281
  let maxChildDepth = 0;
1251
- if (type.tupleTypeArguments) {
1252
- type.tupleTypeArguments.forEach((typeArgInfo) => {
1282
+ if (type.priv.tupleTypeArguments) {
1283
+ type.priv.tupleTypeArguments.forEach((typeArgInfo) => {
1253
1284
  doForEachSubtype(typeArgInfo.type, (subtype) => {
1254
1285
  const childDepth = getContainerDepth(subtype, recursionCount);
1255
1286
  maxChildDepth = Math.max(childDepth, maxChildDepth);
1256
1287
  });
1257
1288
  });
1258
1289
  }
1259
- else if (type.typeArguments) {
1260
- type.typeArguments.forEach((typeArg) => {
1290
+ else if (type.priv.typeArguments) {
1291
+ type.priv.typeArguments.forEach((typeArg) => {
1261
1292
  doForEachSubtype(typeArg, (subtype) => {
1262
1293
  const childDepth = getContainerDepth(subtype, recursionCount);
1263
1294
  maxChildDepth = Math.max(childDepth, maxChildDepth);
@@ -1282,7 +1313,7 @@ exports.lookUpObjectMember = lookUpObjectMember;
1282
1313
  function lookUpClassMember(classType, memberName, flags = 0 /* MemberAccessFlags.Default */, skipMroClass) {
1283
1314
  var _a, _b;
1284
1315
  // Look in the metaclass first.
1285
- const metaclass = classType.details.effectiveMetaclass;
1316
+ const metaclass = classType.shared.effectiveMetaclass;
1286
1317
  // Skip the "type" class as an optimization because it is known to not
1287
1318
  // define any instance variables, and it's by far the most common metaclass.
1288
1319
  if (metaclass && (0, types_1.isClass)(metaclass) && !types_1.ClassType.isBuiltIn(metaclass, 'type')) {
@@ -1440,7 +1471,7 @@ exports.getClassMemberIterator = getClassMemberIterator;
1440
1471
  function* getClassIterator(classType, flags = 0 /* ClassIteratorFlags.Default */, skipMroClass) {
1441
1472
  if ((0, types_1.isClass)(classType)) {
1442
1473
  let foundSkipMroClass = skipMroClass === undefined;
1443
- for (const mroClass of classType.details.mro) {
1474
+ for (const mroClass of classType.shared.mro) {
1444
1475
  // Are we still searching for the skipMroClass?
1445
1476
  if (!foundSkipMroClass && skipMroClass) {
1446
1477
  if (!(0, types_1.isClass)(mroClass)) {
@@ -1516,7 +1547,7 @@ exports.getClassFieldsRecursive = getClassFieldsRecursive;
1516
1547
  // but removing any duplicates.
1517
1548
  function addTypeVarsToListIfUnique(list1, list2, typeVarScopeId) {
1518
1549
  for (const type2 of list2) {
1519
- if (typeVarScopeId && type2.scopeId !== typeVarScopeId) {
1550
+ if (typeVarScopeId && type2.priv.scopeId !== typeVarScopeId) {
1520
1551
  continue;
1521
1552
  }
1522
1553
  if (!list1.find((type1) => (0, types_1.isTypeSame)(convertToInstance(type1), convertToInstance(type2)))) {
@@ -1531,32 +1562,35 @@ exports.addTypeVarsToListIfUnique = addTypeVarsToListIfUnique;
1531
1562
  // Union[List[Dict[_T1, _T2]], _T1, _T3], the result would be
1532
1563
  // [_T1, _T2, _T3].
1533
1564
  function getTypeVarArgumentsRecursive(type, recursionCount = 0) {
1534
- var _a, _b;
1565
+ var _a;
1535
1566
  if (recursionCount > types_1.maxTypeRecursionCount) {
1536
1567
  return [];
1537
1568
  }
1538
1569
  recursionCount++;
1539
- if ((_a = type.typeAliasInfo) === null || _a === void 0 ? void 0 : _a.typeArguments) {
1570
+ const aliasInfo = (_a = type.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo;
1571
+ if (aliasInfo === null || aliasInfo === void 0 ? void 0 : aliasInfo.typeArguments) {
1540
1572
  const combinedList = [];
1541
- (_b = type.typeAliasInfo) === null || _b === void 0 ? void 0 : _b.typeArguments.forEach((typeArg) => {
1573
+ aliasInfo === null || aliasInfo === void 0 ? void 0 : aliasInfo.typeArguments.forEach((typeArg) => {
1542
1574
  addTypeVarsToListIfUnique(combinedList, getTypeVarArgumentsRecursive(typeArg, recursionCount));
1543
1575
  });
1544
1576
  return combinedList;
1545
1577
  }
1546
1578
  if ((0, types_1.isTypeVar)(type)) {
1547
1579
  // Don't return any recursive type alias placeholders.
1548
- if (type.details.recursiveTypeAliasName) {
1580
+ if (type.shared.recursiveAlias) {
1549
1581
  return [];
1550
1582
  }
1551
1583
  // Don't return any P.args or P.kwargs types.
1552
- if ((0, types_1.isParamSpec)(type) && type.paramSpecAccess) {
1584
+ if ((0, types_1.isParamSpec)(type) && type.priv.paramSpecAccess) {
1553
1585
  return [types_1.TypeVarType.cloneForParamSpecAccess(type, /* access */ undefined)];
1554
1586
  }
1555
1587
  return [types_1.TypeBase.isInstantiable(type) ? types_1.TypeVarType.cloneAsInstance(type) : type];
1556
1588
  }
1557
1589
  if ((0, types_1.isClass)(type)) {
1558
1590
  const combinedList = [];
1559
- const typeArgs = type.tupleTypeArguments ? type.tupleTypeArguments.map((e) => e.type) : type.typeArguments;
1591
+ const typeArgs = type.priv.tupleTypeArguments
1592
+ ? type.priv.tupleTypeArguments.map((e) => e.type)
1593
+ : type.priv.typeArguments;
1560
1594
  if (typeArgs) {
1561
1595
  typeArgs.forEach((typeArg) => {
1562
1596
  addTypeVarsToListIfUnique(combinedList, getTypeVarArgumentsRecursive(typeArg, recursionCount));
@@ -1573,7 +1607,7 @@ function getTypeVarArgumentsRecursive(type, recursionCount = 0) {
1573
1607
  }
1574
1608
  if ((0, types_1.isFunction)(type)) {
1575
1609
  const combinedList = [];
1576
- for (let i = 0; i < type.details.parameters.length; i++) {
1610
+ for (let i = 0; i < type.shared.parameters.length; i++) {
1577
1611
  addTypeVarsToListIfUnique(combinedList, getTypeVarArgumentsRecursive(types_1.FunctionType.getEffectiveParameterType(type, i), recursionCount));
1578
1612
  }
1579
1613
  const returnType = types_1.FunctionType.getEffectiveReturnType(type);
@@ -1591,7 +1625,7 @@ function specializeClassType(type) {
1591
1625
  const typeVarContext = new typeVarContext_1.TypeVarContext(getTypeVarScopeId(type));
1592
1626
  const typeParams = types_1.ClassType.getTypeParameters(type);
1593
1627
  typeParams.forEach((typeParam) => {
1594
- typeVarContext.setTypeVarType(typeParam, applySolvedTypeVars(typeParam.details.defaultType, typeVarContext));
1628
+ typeVarContext.setTypeVarType(typeParam, applySolvedTypeVars(typeParam.shared.defaultType, typeVarContext));
1595
1629
  });
1596
1630
  return applySolvedTypeVars(type, typeVarContext);
1597
1631
  }
@@ -1613,37 +1647,37 @@ function setTypeArgumentsRecursive(destType, srcType, typeVarContext, recursionC
1613
1647
  });
1614
1648
  break;
1615
1649
  case 6 /* TypeCategory.Class */:
1616
- if (destType.typeArguments) {
1617
- destType.typeArguments.forEach((typeArg) => {
1650
+ if (destType.priv.typeArguments) {
1651
+ destType.priv.typeArguments.forEach((typeArg) => {
1618
1652
  setTypeArgumentsRecursive(typeArg, srcType, typeVarContext, recursionCount);
1619
1653
  });
1620
1654
  }
1621
- if (destType.tupleTypeArguments) {
1622
- destType.tupleTypeArguments.forEach((typeArg) => {
1655
+ if (destType.priv.tupleTypeArguments) {
1656
+ destType.priv.tupleTypeArguments.forEach((typeArg) => {
1623
1657
  setTypeArgumentsRecursive(typeArg.type, srcType, typeVarContext, recursionCount);
1624
1658
  });
1625
1659
  }
1626
1660
  break;
1627
1661
  case 4 /* TypeCategory.Function */:
1628
- if (destType.specializedTypes) {
1629
- destType.specializedTypes.parameterTypes.forEach((paramType) => {
1662
+ if (destType.priv.specializedTypes) {
1663
+ destType.priv.specializedTypes.parameterTypes.forEach((paramType) => {
1630
1664
  setTypeArgumentsRecursive(paramType, srcType, typeVarContext, recursionCount);
1631
1665
  });
1632
- if (destType.specializedTypes.returnType) {
1633
- setTypeArgumentsRecursive(destType.specializedTypes.returnType, srcType, typeVarContext, recursionCount);
1666
+ if (destType.priv.specializedTypes.returnType) {
1667
+ setTypeArgumentsRecursive(destType.priv.specializedTypes.returnType, srcType, typeVarContext, recursionCount);
1634
1668
  }
1635
1669
  }
1636
1670
  else {
1637
- destType.details.parameters.forEach((param) => {
1671
+ destType.shared.parameters.forEach((param) => {
1638
1672
  setTypeArgumentsRecursive(param.type, srcType, typeVarContext, recursionCount);
1639
1673
  });
1640
- if (destType.details.declaredReturnType) {
1641
- setTypeArgumentsRecursive(destType.details.declaredReturnType, srcType, typeVarContext, recursionCount);
1674
+ if (destType.shared.declaredReturnType) {
1675
+ setTypeArgumentsRecursive(destType.shared.declaredReturnType, srcType, typeVarContext, recursionCount);
1642
1676
  }
1643
1677
  }
1644
1678
  break;
1645
1679
  case 5 /* TypeCategory.OverloadedFunction */:
1646
- destType.overloads.forEach((subtype) => {
1680
+ destType.priv.overloads.forEach((subtype) => {
1647
1681
  setTypeArgumentsRecursive(subtype, srcType, typeVarContext, recursionCount);
1648
1682
  });
1649
1683
  break;
@@ -1661,9 +1695,9 @@ exports.setTypeArgumentsRecursive = setTypeArgumentsRecursive;
1661
1695
  // _T1 with str and _T2 with int.
1662
1696
  function buildTypeVarContextFromSpecializedClass(classType) {
1663
1697
  const typeParameters = types_1.ClassType.getTypeParameters(classType);
1664
- const typeVarContext = buildTypeVarContext(typeParameters, classType.typeArguments, getTypeVarScopeId(classType));
1665
- if (types_1.ClassType.isTupleClass(classType) && classType.tupleTypeArguments) {
1666
- typeVarContext.setTupleTypeVar(typeParameters[0], classType.tupleTypeArguments);
1698
+ const typeVarContext = buildTypeVarContext(typeParameters, classType.priv.typeArguments, getTypeVarScopeId(classType));
1699
+ if (types_1.ClassType.isTupleClass(classType) && classType.priv.tupleTypeArguments) {
1700
+ typeVarContext.setTupleTypeVar(typeParameters[0], classType.priv.tupleTypeArguments);
1667
1701
  }
1668
1702
  return typeVarContext;
1669
1703
  }
@@ -1673,21 +1707,14 @@ function buildTypeVarContext(typeParameters, typeArgs, typeVarScopeId) {
1673
1707
  typeParameters.forEach((typeParam, index) => {
1674
1708
  let typeArgType;
1675
1709
  if (typeArgs) {
1676
- if (typeParam.details.isParamSpec) {
1710
+ if (typeParam.shared.isParamSpec) {
1677
1711
  if (index < typeArgs.length) {
1678
1712
  typeArgType = typeArgs[index];
1679
1713
  if ((0, types_1.isFunction)(typeArgType) && types_1.FunctionType.isParamSpecValue(typeArgType)) {
1680
1714
  const parameters = [];
1681
1715
  const typeArgFunctionType = typeArgType;
1682
- typeArgType.details.parameters.forEach((param, paramIndex) => {
1683
- parameters.push({
1684
- category: param.category,
1685
- name: param.name,
1686
- hasDefault: !!param.hasDefault,
1687
- defaultValueExpression: param.defaultValueExpression,
1688
- isNameSynthesized: param.isNameSynthesized,
1689
- type: types_1.FunctionType.getEffectiveParameterType(typeArgFunctionType, paramIndex),
1690
- });
1716
+ typeArgType.shared.parameters.forEach((param, paramIndex) => {
1717
+ parameters.push(types_1.FunctionParam.create(param.category, types_1.FunctionType.getEffectiveParameterType(typeArgFunctionType, paramIndex), param.flags & types_1.FunctionParamFlags.NameSynthesized, param.name, param.defaultType));
1691
1718
  });
1692
1719
  typeVarContext.setTypeVarType(typeParam, convertTypeToParamSpecValue(typeArgType));
1693
1720
  }
@@ -1726,7 +1753,7 @@ function specializeForBaseClass(srcType, baseClass) {
1726
1753
  }
1727
1754
  exports.specializeForBaseClass = specializeForBaseClass;
1728
1755
  function derivesFromStdlibClass(classType, className) {
1729
- return classType.details.mro.some((mroClass) => (0, types_1.isClass)(mroClass) && types_1.ClassType.isBuiltIn(mroClass, className));
1756
+ return classType.shared.mro.some((mroClass) => (0, types_1.isClass)(mroClass) && types_1.ClassType.isBuiltIn(mroClass, className));
1730
1757
  }
1731
1758
  exports.derivesFromStdlibClass = derivesFromStdlibClass;
1732
1759
  // If ignoreUnknown is true, an unknown base class is ignored when
@@ -1736,7 +1763,7 @@ function derivesFromClassRecursive(classType, baseClassToFind, ignoreUnknown) {
1736
1763
  if (types_1.ClassType.isSameGenericClass(classType, baseClassToFind)) {
1737
1764
  return true;
1738
1765
  }
1739
- for (const baseClass of classType.details.baseClasses) {
1766
+ for (const baseClass of classType.shared.baseClasses) {
1740
1767
  if ((0, types_1.isInstantiableClass)(baseClass)) {
1741
1768
  if (derivesFromClassRecursive(baseClass, baseClassToFind, ignoreUnknown)) {
1742
1769
  return true;
@@ -1754,14 +1781,14 @@ function synthesizeTypeVarForSelfCls(classType, isClsParam) {
1754
1781
  var _a;
1755
1782
  const selfType = types_1.TypeVarType.createInstance(`__type_of_self__`);
1756
1783
  const scopeId = (_a = getTypeVarScopeId(classType)) !== null && _a !== void 0 ? _a : '';
1757
- selfType.details.isSynthesized = true;
1758
- selfType.details.isSynthesizedSelf = true;
1759
- selfType.nameWithScope = types_1.TypeVarType.makeNameWithScope(selfType.details.name, scopeId);
1760
- selfType.scopeId = scopeId;
1784
+ selfType.shared.isSynthesized = true;
1785
+ selfType.shared.isSynthesizedSelf = true;
1786
+ selfType.priv.nameWithScope = types_1.TypeVarType.makeNameWithScope(selfType.shared.name, scopeId);
1787
+ selfType.priv.scopeId = scopeId;
1761
1788
  const boundType = types_1.ClassType.cloneForSpecialization(classType, types_1.ClassType.getTypeParameters(classType),
1762
1789
  /* isTypeArgumentExplicit */ false,
1763
- /* includeSubclasses */ !!classType.includeSubclasses);
1764
- selfType.details.boundType = types_1.ClassType.cloneAsInstance(boundType);
1790
+ /* includeSubclasses */ !!classType.priv.includeSubclasses);
1791
+ selfType.shared.boundType = types_1.ClassType.cloneAsInstance(boundType);
1765
1792
  return isClsParam ? types_1.TypeVarType.cloneAsInstantiable(selfType) : selfType;
1766
1793
  }
1767
1794
  exports.synthesizeTypeVarForSelfCls = synthesizeTypeVarForSelfCls;
@@ -1796,8 +1823,8 @@ function getGeneratorYieldType(declaredReturnType, isAsync) {
1796
1823
  ['', 'AwaitableGenerator'],
1797
1824
  ];
1798
1825
  if (expectedClasses.some((classes) => types_1.ClassType.isBuiltIn(subtype, isAsync ? classes[0] : classes[1]))) {
1799
- return subtype.typeArguments && subtype.typeArguments.length >= 1
1800
- ? subtype.typeArguments[0]
1826
+ return subtype.priv.typeArguments && subtype.priv.typeArguments.length >= 1
1827
+ ? subtype.priv.typeArguments[0]
1801
1828
  : types_1.UnknownType.create();
1802
1829
  }
1803
1830
  }
@@ -1809,31 +1836,40 @@ function getGeneratorYieldType(declaredReturnType, isAsync) {
1809
1836
  exports.getGeneratorYieldType = getGeneratorYieldType;
1810
1837
  function isInstantiableMetaclass(type) {
1811
1838
  return ((0, types_1.isInstantiableClass)(type) &&
1812
- type.details.mro.some((mroClass) => (0, types_1.isClass)(mroClass) && types_1.ClassType.isBuiltIn(mroClass, 'type')));
1839
+ type.shared.mro.some((mroClass) => (0, types_1.isClass)(mroClass) && types_1.ClassType.isBuiltIn(mroClass, 'type')));
1813
1840
  }
1814
1841
  exports.isInstantiableMetaclass = isInstantiableMetaclass;
1815
1842
  function isMetaclassInstance(type) {
1816
1843
  return ((0, types_1.isClassInstance)(type) &&
1817
- type.details.mro.some((mroClass) => (0, types_1.isClass)(mroClass) && types_1.ClassType.isBuiltIn(mroClass, 'type')));
1844
+ type.shared.mro.some((mroClass) => (0, types_1.isClass)(mroClass) && types_1.ClassType.isBuiltIn(mroClass, 'type')));
1818
1845
  }
1819
1846
  exports.isMetaclassInstance = isMetaclassInstance;
1820
- function isEffectivelyInstantiable(type) {
1847
+ function isEffectivelyInstantiable(type, options, recursionCount = 0) {
1848
+ if (recursionCount > types_1.maxTypeRecursionCount) {
1849
+ return false;
1850
+ }
1851
+ recursionCount++;
1821
1852
  if (types_1.TypeBase.isInstantiable(type)) {
1822
1853
  return true;
1823
1854
  }
1855
+ if ((options === null || options === void 0 ? void 0 : options.honorTypeVarBounds) && (0, types_1.isTypeVar)(type) && type.shared.boundType) {
1856
+ if (isEffectivelyInstantiable(type.shared.boundType, options, recursionCount)) {
1857
+ return true;
1858
+ }
1859
+ }
1824
1860
  // Handle the special case of 'type' (or subclasses thereof),
1825
1861
  // which are instantiable.
1826
1862
  if (isMetaclassInstance(type)) {
1827
1863
  return true;
1828
1864
  }
1829
1865
  if ((0, types_1.isUnion)(type)) {
1830
- return type.subtypes.every((subtype) => isEffectivelyInstantiable(subtype));
1866
+ return type.priv.subtypes.every((subtype) => isEffectivelyInstantiable(subtype, options, recursionCount));
1831
1867
  }
1832
1868
  return false;
1833
1869
  }
1834
1870
  exports.isEffectivelyInstantiable = isEffectivelyInstantiable;
1835
1871
  function convertToInstance(type, includeSubclasses = true) {
1836
- var _a;
1872
+ var _a, _b;
1837
1873
  // See if we've already performed this conversion and cached it.
1838
1874
  if (((_a = type.cached) === null || _a === void 0 ? void 0 : _a.instanceType) && includeSubclasses) {
1839
1875
  return type.cached.instanceType;
@@ -1844,17 +1880,17 @@ function convertToInstance(type, includeSubclasses = true) {
1844
1880
  // Handle type[x] as a special case.
1845
1881
  if (types_1.ClassType.isBuiltIn(subtype, 'type')) {
1846
1882
  if (types_1.TypeBase.isInstance(subtype)) {
1847
- if (!subtype.typeArguments || subtype.typeArguments.length < 1) {
1883
+ if (!subtype.priv.typeArguments || subtype.priv.typeArguments.length < 1) {
1848
1884
  return types_1.UnknownType.create();
1849
1885
  }
1850
1886
  else {
1851
- return subtype.typeArguments[0];
1887
+ return subtype.priv.typeArguments[0];
1852
1888
  }
1853
1889
  }
1854
1890
  else {
1855
- if (subtype.typeArguments && subtype.typeArguments.length > 0) {
1856
- if (!(0, types_1.isAnyOrUnknown)(subtype.typeArguments[0])) {
1857
- return convertToInstantiable(subtype.typeArguments[0]);
1891
+ if (subtype.priv.typeArguments && subtype.priv.typeArguments.length > 0) {
1892
+ if (!(0, types_1.isAnyOrUnknown)(subtype.priv.typeArguments[0])) {
1893
+ return convertToInstantiable(subtype.priv.typeArguments[0]);
1858
1894
  }
1859
1895
  }
1860
1896
  }
@@ -1887,10 +1923,13 @@ function convertToInstance(type, includeSubclasses = true) {
1887
1923
  }
1888
1924
  }
1889
1925
  return subtype;
1926
+ }, {
1927
+ skipElideRedundantLiterals: true,
1890
1928
  });
1891
1929
  // Copy over any type alias information.
1892
- if (type.typeAliasInfo && type !== result) {
1893
- result = types_1.TypeBase.cloneForTypeAlias(result, type.typeAliasInfo.name, type.typeAliasInfo.fullName, type.typeAliasInfo.moduleName, type.typeAliasInfo.fileUri, type.typeAliasInfo.typeVarScopeId, type.typeAliasInfo.isPep695Syntax, type.typeAliasInfo.typeParameters, type.typeAliasInfo.typeArguments);
1930
+ const aliasInfo = (_b = type.props) === null || _b === void 0 ? void 0 : _b.typeAliasInfo;
1931
+ if (aliasInfo && type !== result) {
1932
+ result = types_1.TypeBase.cloneForTypeAlias(result, aliasInfo.name, aliasInfo.fullName, aliasInfo.moduleName, aliasInfo.fileUri, aliasInfo.typeVarScopeId, aliasInfo.isPep695Syntax, aliasInfo.typeParameters, aliasInfo.typeArguments);
1894
1933
  }
1895
1934
  if (type !== result && includeSubclasses) {
1896
1935
  // Cache the converted value for next time.
@@ -1933,7 +1972,7 @@ function convertToInstantiable(type, includeSubclasses = true) {
1933
1972
  }
1934
1973
  exports.convertToInstantiable = convertToInstantiable;
1935
1974
  function getMembersForClass(classType, symbolTable, includeInstanceVars) {
1936
- classType.details.mro.forEach((mroClass) => {
1975
+ classType.shared.mro.forEach((mroClass) => {
1937
1976
  if ((0, types_1.isInstantiableClass)(mroClass)) {
1938
1977
  // Add any new member variables from this class.
1939
1978
  const isClassTypedDict = types_1.ClassType.isTypedDictClass(mroClass);
@@ -1958,9 +1997,9 @@ function getMembersForClass(classType, symbolTable, includeInstanceVars) {
1958
1997
  });
1959
1998
  // Add members of the metaclass as well.
1960
1999
  if (!includeInstanceVars) {
1961
- const metaclass = classType.details.effectiveMetaclass;
2000
+ const metaclass = classType.shared.effectiveMetaclass;
1962
2001
  if (metaclass && (0, types_1.isInstantiableClass)(metaclass)) {
1963
- for (const mroClass of metaclass.details.mro) {
2002
+ for (const mroClass of metaclass.shared.mro) {
1964
2003
  if ((0, types_1.isInstantiableClass)(mroClass)) {
1965
2004
  types_1.ClassType.getSymbolTable(mroClass).forEach((symbol, name) => {
1966
2005
  const existingSymbol = symbolTable.get(name);
@@ -1986,12 +2025,12 @@ function getMembersForModule(moduleType, symbolTable) {
1986
2025
  // Start with the loader fields. If there are any symbols of the
1987
2026
  // same name defined within the module, they will overwrite the
1988
2027
  // loader fields.
1989
- if (moduleType.loaderFields) {
1990
- moduleType.loaderFields.forEach((symbol, name) => {
2028
+ if (moduleType.priv.loaderFields) {
2029
+ moduleType.priv.loaderFields.forEach((symbol, name) => {
1991
2030
  symbolTable.set(name, symbol);
1992
2031
  });
1993
2032
  }
1994
- moduleType.fields.forEach((symbol, name) => {
2033
+ moduleType.priv.fields.forEach((symbol, name) => {
1995
2034
  symbolTable.set(name, symbol);
1996
2035
  });
1997
2036
  }
@@ -2030,6 +2069,9 @@ function containsAnyOrUnknown(type, recurse) {
2030
2069
  super();
2031
2070
  this._recurse = _recurse;
2032
2071
  }
2072
+ visitTypeAlias(type) {
2073
+ // Don't explore type aliases.
2074
+ }
2033
2075
  visitUnknown(type) {
2034
2076
  this.anyOrUnknownType = this.anyOrUnknownType ? preserveUnknown(this.anyOrUnknownType, type) : type;
2035
2077
  }
@@ -2073,8 +2115,9 @@ function isPartlyUnknown(type, recursionCount = 0) {
2073
2115
  }
2074
2116
  // If this is a generic type alias, see if any of its type arguments
2075
2117
  // are either unspecified or are partially known.
2076
- if ((_a = type.typeAliasInfo) === null || _a === void 0 ? void 0 : _a.typeArguments) {
2077
- if (type.typeAliasInfo.typeArguments.some((typeArg) => isPartlyUnknown(typeArg, recursionCount))) {
2118
+ const aliasInfo = (_a = type.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo;
2119
+ if (aliasInfo === null || aliasInfo === void 0 ? void 0 : aliasInfo.typeArguments) {
2120
+ if (aliasInfo.typeArguments.some((typeArg) => isPartlyUnknown(typeArg, recursionCount))) {
2078
2121
  return true;
2079
2122
  }
2080
2123
  }
@@ -2087,11 +2130,11 @@ function isPartlyUnknown(type, recursionCount = 0) {
2087
2130
  // If this is a reference to the class itself, as opposed to a reference
2088
2131
  // to a type that represents the class and its subclasses, don't flag
2089
2132
  // the type as partially unknown.
2090
- if (!type.includeSubclasses) {
2133
+ if (!type.priv.includeSubclasses) {
2091
2134
  return false;
2092
2135
  }
2093
2136
  if (!types_1.ClassType.isPseudoGenericClass(type)) {
2094
- const typeArgs = ((_b = type.tupleTypeArguments) === null || _b === void 0 ? void 0 : _b.map((t) => t.type)) || type.typeArguments;
2137
+ const typeArgs = ((_b = type.priv.tupleTypeArguments) === null || _b === void 0 ? void 0 : _b.map((t) => t.type)) || type.priv.typeArguments;
2095
2138
  if (typeArgs) {
2096
2139
  for (const argType of typeArgs) {
2097
2140
  if (isPartlyUnknown(argType, recursionCount)) {
@@ -2109,18 +2152,18 @@ function isPartlyUnknown(type, recursionCount = 0) {
2109
2152
  });
2110
2153
  }
2111
2154
  if ((0, types_1.isFunction)(type)) {
2112
- for (let i = 0; i < type.details.parameters.length; i++) {
2155
+ for (let i = 0; i < type.shared.parameters.length; i++) {
2113
2156
  // Ignore parameters such as "*" that have no name.
2114
- if (type.details.parameters[i].name) {
2157
+ if (type.shared.parameters[i].name) {
2115
2158
  const paramType = types_1.FunctionType.getEffectiveParameterType(type, i);
2116
2159
  if (isPartlyUnknown(paramType, recursionCount)) {
2117
2160
  return true;
2118
2161
  }
2119
2162
  }
2120
2163
  }
2121
- if (type.details.declaredReturnType &&
2164
+ if (type.shared.declaredReturnType &&
2122
2165
  !types_1.FunctionType.isParamSpecValue(type) &&
2123
- isPartlyUnknown(type.details.declaredReturnType, recursionCount)) {
2166
+ isPartlyUnknown(type.shared.declaredReturnType, recursionCount)) {
2124
2167
  return true;
2125
2168
  }
2126
2169
  return false;
@@ -2132,10 +2175,12 @@ exports.isPartlyUnknown = isPartlyUnknown;
2132
2175
  // that is a union, it "explodes" the class into a union of classes with
2133
2176
  // each element of the union - e.g. Foo[A | B] becomes Foo[A] | Foo[B].
2134
2177
  function explodeGenericClass(classType) {
2135
- if (!classType.typeArguments || classType.typeArguments.length !== 1 || !(0, types_1.isUnion)(classType.typeArguments[0])) {
2178
+ if (!classType.priv.typeArguments ||
2179
+ classType.priv.typeArguments.length !== 1 ||
2180
+ !(0, types_1.isUnion)(classType.priv.typeArguments[0])) {
2136
2181
  return classType;
2137
2182
  }
2138
- return (0, types_1.combineTypes)(classType.typeArguments[0].subtypes.map((subtype) => {
2183
+ return (0, types_1.combineTypes)(classType.priv.typeArguments[0].priv.subtypes.map((subtype) => {
2139
2184
  return types_1.ClassType.cloneForSpecialization(classType, [subtype], /* isTypeArgumentExplicit */ true);
2140
2185
  }));
2141
2186
  }
@@ -2157,12 +2202,12 @@ function combineSameSizedTuples(type, tupleType) {
2157
2202
  if (!tupleClass) {
2158
2203
  // Look in the mro list to see if this subtype derives from a
2159
2204
  // tuple with a known size. This includes named tuples.
2160
- tupleClass = subtype.details.mro.find((mroClass) => (0, types_1.isClass)(mroClass) && isTupleClass(mroClass) && !isUnboundedTupleClass(mroClass));
2205
+ tupleClass = subtype.shared.mro.find((mroClass) => (0, types_1.isClass)(mroClass) && isTupleClass(mroClass) && !isUnboundedTupleClass(mroClass));
2161
2206
  }
2162
- if (tupleClass && (0, types_1.isClass)(tupleClass) && tupleClass.tupleTypeArguments) {
2207
+ if (tupleClass && (0, types_1.isClass)(tupleClass) && tupleClass.priv.tupleTypeArguments) {
2163
2208
  if (tupleEntries) {
2164
- if (tupleEntries.length === tupleClass.tupleTypeArguments.length) {
2165
- tupleClass.tupleTypeArguments.forEach((entry, index) => {
2209
+ if (tupleEntries.length === tupleClass.priv.tupleTypeArguments.length) {
2210
+ tupleClass.priv.tupleTypeArguments.forEach((entry, index) => {
2166
2211
  tupleEntries[index].push(entry.type);
2167
2212
  });
2168
2213
  }
@@ -2171,7 +2216,7 @@ function combineSameSizedTuples(type, tupleType) {
2171
2216
  }
2172
2217
  }
2173
2218
  else {
2174
- tupleEntries = tupleClass.tupleTypeArguments.map((entry) => [entry.type]);
2219
+ tupleEntries = tupleClass.priv.tupleTypeArguments.map((entry) => [entry.type]);
2175
2220
  }
2176
2221
  }
2177
2222
  else {
@@ -2204,14 +2249,14 @@ function specializeTupleClass(classType, typeArgs, isTypeArgumentExplicit = true
2204
2249
  const clonedClassType = types_1.ClassType.cloneForSpecialization(classType, [combinedTupleType], isTypeArgumentExplicit,
2205
2250
  /* includeSubclasses */ undefined, typeArgs);
2206
2251
  if (isUnpackedTuple) {
2207
- clonedClassType.isUnpacked = true;
2252
+ clonedClassType.priv.isUnpacked = true;
2208
2253
  }
2209
2254
  return clonedClassType;
2210
2255
  }
2211
2256
  exports.specializeTupleClass = specializeTupleClass;
2212
2257
  function _expandVariadicUnpackedUnion(type) {
2213
- if ((0, types_1.isClassInstance)(type) && isTupleClass(type) && type.tupleTypeArguments && type.isUnpacked) {
2214
- return (0, types_1.combineTypes)(type.tupleTypeArguments.map((t) => t.type));
2258
+ if ((0, types_1.isClassInstance)(type) && isTupleClass(type) && type.priv.tupleTypeArguments && type.priv.isUnpacked) {
2259
+ return (0, types_1.combineTypes)(type.priv.tupleTypeArguments.map((t) => t.type));
2215
2260
  }
2216
2261
  return type;
2217
2262
  }
@@ -2221,29 +2266,29 @@ function getGeneratorTypeArgs(returnType) {
2221
2266
  var _a;
2222
2267
  if ((0, types_1.isClassInstance)(returnType)) {
2223
2268
  if (types_1.ClassType.isBuiltIn(returnType, ['Generator', 'AsyncGenerator'])) {
2224
- return returnType.typeArguments;
2269
+ return returnType.priv.typeArguments;
2225
2270
  }
2226
2271
  else if (types_1.ClassType.isBuiltIn(returnType, 'AwaitableGenerator')) {
2227
2272
  // AwaitableGenerator has four type arguments, and the first 3
2228
2273
  // correspond to the generator.
2229
- return (_a = returnType.typeArguments) === null || _a === void 0 ? void 0 : _a.slice(0, 3);
2274
+ return (_a = returnType.priv.typeArguments) === null || _a === void 0 ? void 0 : _a.slice(0, 3);
2230
2275
  }
2231
2276
  }
2232
2277
  return undefined;
2233
2278
  }
2234
2279
  exports.getGeneratorTypeArgs = getGeneratorTypeArgs;
2235
2280
  function requiresTypeArguments(classType) {
2236
- if (classType.details.typeParameters.length > 0) {
2237
- const firstTypeParam = classType.details.typeParameters[0];
2281
+ if (classType.shared.typeParameters.length > 0) {
2282
+ const firstTypeParam = classType.shared.typeParameters[0];
2238
2283
  // If there are type parameters, type arguments are needed.
2239
2284
  // The exception is if type parameters have been synthesized
2240
2285
  // for classes that have untyped constructors.
2241
- if (firstTypeParam.details.isSynthesized) {
2286
+ if (firstTypeParam.shared.isSynthesized) {
2242
2287
  return false;
2243
2288
  }
2244
2289
  // If the first type parameter has a default type, then no
2245
2290
  // type arguments are needed.
2246
- if (firstTypeParam.details.isDefaultExplicit) {
2291
+ if (firstTypeParam.shared.isDefaultExplicit) {
2247
2292
  return false;
2248
2293
  }
2249
2294
  return true;
@@ -2263,7 +2308,7 @@ function requiresTypeArguments(classType) {
2263
2308
  'TypeGuard',
2264
2309
  'TypeIs',
2265
2310
  ];
2266
- if (specialClasses.some((t) => t === (classType.aliasName || classType.details.name))) {
2311
+ if (specialClasses.some((t) => t === (classType.priv.aliasName || classType.shared.name))) {
2267
2312
  return true;
2268
2313
  }
2269
2314
  }
@@ -2292,9 +2337,9 @@ function requiresSpecialization(type, options, recursionCount = 0) {
2292
2337
  }
2293
2338
  exports.requiresSpecialization = requiresSpecialization;
2294
2339
  function _requiresSpecialization(type, options, recursionCount = 0) {
2295
- var _a;
2340
+ var _a, _b;
2296
2341
  // If the type is conditioned on a TypeVar, it may need to be specialized.
2297
- if (type.condition) {
2342
+ if ((_a = type.props) === null || _a === void 0 ? void 0 : _a.condition) {
2298
2343
  return true;
2299
2344
  }
2300
2345
  switch (type.category) {
@@ -2302,53 +2347,54 @@ function _requiresSpecialization(type, options, recursionCount = 0) {
2302
2347
  if (types_1.ClassType.isPseudoGenericClass(type) && (options === null || options === void 0 ? void 0 : options.ignorePseudoGeneric)) {
2303
2348
  return false;
2304
2349
  }
2305
- if (!type.isTypeArgumentExplicit && (options === null || options === void 0 ? void 0 : options.ignoreImplicitTypeArgs)) {
2350
+ if (!type.priv.isTypeArgumentExplicit && (options === null || options === void 0 ? void 0 : options.ignoreImplicitTypeArgs)) {
2306
2351
  return false;
2307
2352
  }
2308
- if (type.typeArguments) {
2309
- return type.typeArguments.some((typeArg) => requiresSpecialization(typeArg, options, recursionCount));
2353
+ if (type.priv.typeArguments) {
2354
+ return type.priv.typeArguments.some((typeArg) => requiresSpecialization(typeArg, options, recursionCount));
2310
2355
  }
2311
2356
  return types_1.ClassType.getTypeParameters(type).length > 0;
2312
2357
  }
2313
2358
  case 4 /* TypeCategory.Function */: {
2314
- for (let i = 0; i < type.details.parameters.length; i++) {
2359
+ for (let i = 0; i < type.shared.parameters.length; i++) {
2315
2360
  if (requiresSpecialization(types_1.FunctionType.getEffectiveParameterType(type, i), options, recursionCount)) {
2316
2361
  return true;
2317
2362
  }
2318
2363
  }
2319
- const declaredReturnType = type.specializedTypes && type.specializedTypes.returnType
2320
- ? type.specializedTypes.returnType
2321
- : type.details.declaredReturnType;
2364
+ const declaredReturnType = type.priv.specializedTypes && type.priv.specializedTypes.returnType
2365
+ ? type.priv.specializedTypes.returnType
2366
+ : type.shared.declaredReturnType;
2322
2367
  if (declaredReturnType) {
2323
2368
  if (requiresSpecialization(declaredReturnType, options, recursionCount)) {
2324
2369
  return true;
2325
2370
  }
2326
2371
  }
2327
- else if (type.inferredReturnType) {
2328
- if (requiresSpecialization(type.inferredReturnType, options, recursionCount)) {
2372
+ else if (type.priv.inferredReturnType) {
2373
+ if (requiresSpecialization(type.priv.inferredReturnType, options, recursionCount)) {
2329
2374
  return true;
2330
2375
  }
2331
2376
  }
2332
2377
  return false;
2333
2378
  }
2334
2379
  case 5 /* TypeCategory.OverloadedFunction */: {
2335
- return type.overloads.some((overload) => requiresSpecialization(overload, options, recursionCount));
2380
+ return type.priv.overloads.some((overload) => requiresSpecialization(overload, options, recursionCount));
2336
2381
  }
2337
2382
  case 8 /* TypeCategory.Union */: {
2338
- return type.subtypes.some((subtype) => requiresSpecialization(subtype, options, recursionCount));
2383
+ return type.priv.subtypes.some((subtype) => requiresSpecialization(subtype, options, recursionCount));
2339
2384
  }
2340
2385
  case 9 /* TypeCategory.TypeVar */: {
2341
2386
  // Most TypeVar types need to be specialized.
2342
- if (!type.details.recursiveTypeAliasName) {
2343
- if (type.details.isSynthesizedSelf && (options === null || options === void 0 ? void 0 : options.ignoreSelf)) {
2387
+ if (!type.shared.recursiveAlias) {
2388
+ if (type.shared.isSynthesizedSelf && (options === null || options === void 0 ? void 0 : options.ignoreSelf)) {
2344
2389
  return false;
2345
2390
  }
2346
2391
  return true;
2347
2392
  }
2348
2393
  // If this is a recursive type alias, it may need to be specialized
2349
2394
  // if it has generic type arguments.
2350
- if ((_a = type.typeAliasInfo) === null || _a === void 0 ? void 0 : _a.typeArguments) {
2351
- return type.typeAliasInfo.typeArguments.some((typeArg) => requiresSpecialization(typeArg, options, recursionCount));
2395
+ const aliasInfo = (_b = type.props) === null || _b === void 0 ? void 0 : _b.typeAliasInfo;
2396
+ if (aliasInfo === null || aliasInfo === void 0 ? void 0 : aliasInfo.typeArguments) {
2397
+ return aliasInfo.typeArguments.some((typeArg) => requiresSpecialization(typeArg, options, recursionCount));
2352
2398
  }
2353
2399
  }
2354
2400
  }
@@ -2373,23 +2419,23 @@ function isVarianceOfTypeArgumentCompatible(type, typeParamVariance) {
2373
2419
  if (typeParamVariance === 1 /* Variance.Unknown */ || typeParamVariance === 0 /* Variance.Auto */) {
2374
2420
  return true;
2375
2421
  }
2376
- if ((0, types_1.isTypeVar)(type) && !type.details.isParamSpec && !type.details.isVariadic) {
2377
- const typeArgVariance = type.details.declaredVariance;
2422
+ if ((0, types_1.isTypeVar)(type) && !type.shared.isParamSpec && !type.shared.isVariadic) {
2423
+ const typeArgVariance = type.shared.declaredVariance;
2378
2424
  if (typeArgVariance === 4 /* Variance.Contravariant */ || typeArgVariance === 3 /* Variance.Covariant */) {
2379
2425
  return typeArgVariance === typeParamVariance;
2380
2426
  }
2381
2427
  }
2382
2428
  else if ((0, types_1.isClassInstance)(type)) {
2383
- if (type.details.typeParameters && type.details.typeParameters.length > 0) {
2384
- return type.details.typeParameters.every((typeParam, index) => {
2429
+ if (type.shared.typeParameters && type.shared.typeParameters.length > 0) {
2430
+ return type.shared.typeParameters.every((typeParam, index) => {
2385
2431
  let typeArgType;
2386
- if (typeParam.details.isParamSpec || typeParam.details.isVariadic) {
2432
+ if (typeParam.shared.isParamSpec || typeParam.shared.isVariadic) {
2387
2433
  return true;
2388
2434
  }
2389
- if (type.typeArguments && index < type.typeArguments.length) {
2390
- typeArgType = type.typeArguments[index];
2435
+ if (type.priv.typeArguments && index < type.priv.typeArguments.length) {
2436
+ typeArgType = type.priv.typeArguments[index];
2391
2437
  }
2392
- const declaredVariance = typeParam.details.declaredVariance;
2438
+ const declaredVariance = typeParam.shared.declaredVariance;
2393
2439
  if (declaredVariance === 0 /* Variance.Auto */) {
2394
2440
  return true;
2395
2441
  }
@@ -2423,8 +2469,8 @@ exports.isVarianceOfTypeArgumentCompatible = isVarianceOfTypeArgumentCompatible;
2423
2469
  function computeMroLinearization(classType) {
2424
2470
  let isMroFound = true;
2425
2471
  // Clear out any existing MRO information.
2426
- classType.details.mro = [];
2427
- const filteredBaseClasses = classType.details.baseClasses.filter((baseClass, index) => {
2472
+ classType.shared.mro = [];
2473
+ const filteredBaseClasses = classType.shared.baseClasses.filter((baseClass, index) => {
2428
2474
  if ((0, types_1.isInstantiableClass)(baseClass)) {
2429
2475
  // Generic has some special-case logic (see description of __mro_entries__
2430
2476
  // in PEP 560) that we need to account for here.
@@ -2437,11 +2483,11 @@ function computeMroLinearization(classType) {
2437
2483
  // If the class contains any specialized generic classes after
2438
2484
  // the Generic base, the Generic base is ignored for purposes
2439
2485
  // of computing the MRO.
2440
- if (classType.details.baseClasses.some((innerBaseClass, innerIndex) => {
2486
+ if (classType.shared.baseClasses.some((innerBaseClass, innerIndex) => {
2441
2487
  return (innerIndex > index &&
2442
2488
  (0, types_1.isInstantiableClass)(innerBaseClass) &&
2443
- innerBaseClass.typeArguments &&
2444
- innerBaseClass.isTypeArgumentExplicit);
2489
+ innerBaseClass.priv.typeArguments &&
2490
+ innerBaseClass.priv.isTypeArgumentExplicit);
2445
2491
  })) {
2446
2492
  return false;
2447
2493
  }
@@ -2454,7 +2500,7 @@ function computeMroLinearization(classType) {
2454
2500
  filteredBaseClasses.forEach((baseClass) => {
2455
2501
  if ((0, types_1.isInstantiableClass)(baseClass)) {
2456
2502
  const typeVarContext = buildTypeVarContextFromSpecializedClass(baseClass);
2457
- classListsToMerge.push(baseClass.details.mro.map((mroClass) => {
2503
+ classListsToMerge.push(baseClass.shared.mro.map((mroClass) => {
2458
2504
  return applySolvedTypeVars(mroClass, typeVarContext);
2459
2505
  }));
2460
2506
  }
@@ -2472,7 +2518,7 @@ function computeMroLinearization(classType) {
2472
2518
  if (!(0, types_1.isClass)(specializedClassType) && !(0, types_1.isAnyOrUnknown)(specializedClassType)) {
2473
2519
  specializedClassType = types_1.UnknownType.create();
2474
2520
  }
2475
- classType.details.mro.push(specializedClassType);
2521
+ classType.shared.mro.push(specializedClassType);
2476
2522
  // Helper function that returns true if the specified searchClass
2477
2523
  // is found in the "tail" (i.e. in elements 1 through n) of any
2478
2524
  // of the class lists.
@@ -2506,13 +2552,13 @@ function computeMroLinearization(classType) {
2506
2552
  if (!(0, types_1.isClass)(head) && !(0, types_1.isAnyOrUnknown)(head)) {
2507
2553
  head = types_1.UnknownType.create();
2508
2554
  }
2509
- classType.details.mro.push(head);
2555
+ classType.shared.mro.push(head);
2510
2556
  classList.shift();
2511
2557
  break;
2512
2558
  }
2513
2559
  if (!isInTail(classList[0], classListsToMerge)) {
2514
2560
  foundValidHead = true;
2515
- classType.details.mro.push(classList[0]);
2561
+ classType.shared.mro.push(classList[0]);
2516
2562
  filterClass(classList[0], classListsToMerge);
2517
2563
  break;
2518
2564
  }
@@ -2534,11 +2580,11 @@ function computeMroLinearization(classType) {
2534
2580
  if (!(0, types_1.isClass)(head) && !(0, types_1.isAnyOrUnknown)(head)) {
2535
2581
  head = types_1.UnknownType.create();
2536
2582
  }
2537
- classType.details.mro.push(head);
2583
+ classType.shared.mro.push(head);
2538
2584
  nonEmptyList.shift();
2539
2585
  }
2540
2586
  else {
2541
- classType.details.mro.push(nonEmptyList[0]);
2587
+ classType.shared.mro.push(nonEmptyList[0]);
2542
2588
  filterClass(nonEmptyList[0], classListsToMerge);
2543
2589
  }
2544
2590
  }
@@ -2555,6 +2601,14 @@ function getDeclaringModulesForType(type) {
2555
2601
  return moduleList;
2556
2602
  }
2557
2603
  exports.getDeclaringModulesForType = getDeclaringModulesForType;
2604
+ function convertArgumentNodeToFunctionArgument(node) {
2605
+ return {
2606
+ argumentCategory: node.d.argCategory,
2607
+ name: node.d.name,
2608
+ valueExpression: node.d.valueExpr,
2609
+ };
2610
+ }
2611
+ exports.convertArgumentNodeToFunctionArgument = convertArgumentNodeToFunctionArgument;
2558
2612
  function addDeclaringModuleNamesForType(type, moduleList, recursionCount = 0) {
2559
2613
  if (recursionCount > types_1.maxTypeRecursionCount) {
2560
2614
  return;
@@ -2567,15 +2621,15 @@ function addDeclaringModuleNamesForType(type, moduleList, recursionCount = 0) {
2567
2621
  };
2568
2622
  switch (type.category) {
2569
2623
  case 6 /* TypeCategory.Class */: {
2570
- addIfUnique(type.details.moduleName);
2624
+ addIfUnique(type.shared.moduleName);
2571
2625
  break;
2572
2626
  }
2573
2627
  case 4 /* TypeCategory.Function */: {
2574
- addIfUnique(type.details.moduleName);
2628
+ addIfUnique(type.shared.moduleName);
2575
2629
  break;
2576
2630
  }
2577
2631
  case 5 /* TypeCategory.OverloadedFunction */: {
2578
- type.overloads.forEach((overload) => {
2632
+ type.priv.overloads.forEach((overload) => {
2579
2633
  addDeclaringModuleNamesForType(overload, moduleList, recursionCount);
2580
2634
  });
2581
2635
  break;
@@ -2587,7 +2641,7 @@ function addDeclaringModuleNamesForType(type, moduleList, recursionCount = 0) {
2587
2641
  break;
2588
2642
  }
2589
2643
  case 7 /* TypeCategory.Module */: {
2590
- addIfUnique(type.moduleName);
2644
+ addIfUnique(type.priv.moduleName);
2591
2645
  break;
2592
2646
  }
2593
2647
  }
@@ -2599,27 +2653,20 @@ function convertTypeToParamSpecValue(type) {
2599
2653
  if ((0, types_1.isParamSpec)(type)) {
2600
2654
  const newFunction = types_1.FunctionType.createInstance('', '', '', 65536 /* FunctionTypeFlags.ParamSpecValue */);
2601
2655
  types_1.FunctionType.addParamSpecVariadics(newFunction, type);
2602
- newFunction.details.typeVarScopeId = getTypeVarScopeId(type);
2656
+ newFunction.shared.typeVarScopeId = getTypeVarScopeId(type);
2603
2657
  return newFunction;
2604
2658
  }
2605
2659
  if ((0, types_1.isFunction)(type)) {
2606
- const newFunction = types_1.FunctionType.createInstance('', '', '', type.details.flags | 65536 /* FunctionTypeFlags.ParamSpecValue */, type.details.docString);
2607
- newFunction.details.deprecatedMessage = type.details.deprecatedMessage;
2608
- type.details.parameters.forEach((param, index) => {
2609
- types_1.FunctionType.addParameter(newFunction, {
2610
- category: param.category,
2611
- name: param.name,
2612
- hasDefault: param.hasDefault,
2613
- defaultValueExpression: param.defaultValueExpression,
2614
- isNameSynthesized: param.isNameSynthesized,
2615
- type: types_1.FunctionType.getEffectiveParameterType(type, index),
2616
- });
2660
+ const newFunction = types_1.FunctionType.createInstance('', '', '', type.shared.flags | 65536 /* FunctionTypeFlags.ParamSpecValue */, type.shared.docString);
2661
+ newFunction.shared.deprecatedMessage = type.shared.deprecatedMessage;
2662
+ type.shared.parameters.forEach((param, index) => {
2663
+ types_1.FunctionType.addParameter(newFunction, types_1.FunctionParam.create(param.category, types_1.FunctionType.getEffectiveParameterType(type, index), param.flags & types_1.FunctionParamFlags.NameSynthesized, param.name, param.defaultType));
2617
2664
  });
2618
- if (type.details.higherOrderTypeVarScopeIds) {
2619
- newFunction.details.higherOrderTypeVarScopeIds = [...type.details.higherOrderTypeVarScopeIds];
2620
- newFunction.details.typeVarScopeId = newFunction.details.higherOrderTypeVarScopeIds.pop();
2665
+ if (type.priv.higherOrderTypeVarScopeIds) {
2666
+ newFunction.priv.higherOrderTypeVarScopeIds = [...type.priv.higherOrderTypeVarScopeIds];
2667
+ newFunction.shared.typeVarScopeId = newFunction.priv.higherOrderTypeVarScopeIds.pop();
2621
2668
  }
2622
- newFunction.details.constructorTypeVarScopeId = type.details.constructorTypeVarScopeId;
2669
+ newFunction.priv.constructorTypeVarScopeId = type.priv.constructorTypeVarScopeId;
2623
2670
  return newFunction;
2624
2671
  }
2625
2672
  return getUnknownTypeForParamSpec();
@@ -2630,11 +2677,11 @@ exports.convertTypeToParamSpecValue = convertTypeToParamSpecValue;
2630
2677
  function convertParamSpecValueToType(type) {
2631
2678
  const paramSpec = types_1.FunctionType.getParamSpecFromArgsKwargs(type);
2632
2679
  const withoutParamSpec = types_1.FunctionType.cloneRemoveParamSpecArgsKwargs(type);
2633
- let hasParameters = withoutParamSpec.details.parameters.length > 0;
2634
- if (withoutParamSpec.details.parameters.length === 1) {
2680
+ let hasParameters = withoutParamSpec.shared.parameters.length > 0;
2681
+ if (withoutParamSpec.shared.parameters.length === 1) {
2635
2682
  // If the ParamSpec has a position-only separator as its only parameter,
2636
2683
  // treat it as though there are no parameters.
2637
- const onlyParam = withoutParamSpec.details.parameters[0];
2684
+ const onlyParam = withoutParamSpec.shared.parameters[0];
2638
2685
  if ((0, types_1.isPositionOnlySeparator)(onlyParam)) {
2639
2686
  hasParameters = false;
2640
2687
  }
@@ -2644,27 +2691,19 @@ function convertParamSpecValueToType(type) {
2644
2691
  return paramSpec;
2645
2692
  }
2646
2693
  // Create a function type from the param spec entries.
2647
- const functionType = types_1.FunctionType.createInstance('', '', '', 65536 /* FunctionTypeFlags.ParamSpecValue */ | withoutParamSpec.details.flags);
2648
- types_1.FunctionType.addHigherOrderTypeVarScopeIds(functionType, withoutParamSpec.details.typeVarScopeId);
2649
- types_1.FunctionType.addHigherOrderTypeVarScopeIds(functionType, withoutParamSpec.details.higherOrderTypeVarScopeIds);
2650
- functionType.details.constructorTypeVarScopeId = withoutParamSpec.details.constructorTypeVarScopeId;
2651
- withoutParamSpec.details.parameters.forEach((entry, index) => {
2652
- types_1.FunctionType.addParameter(functionType, {
2653
- category: entry.category,
2654
- name: entry.name,
2655
- hasDefault: entry.hasDefault,
2656
- defaultValueExpression: entry.defaultValueExpression,
2657
- isNameSynthesized: entry.isNameSynthesized,
2658
- hasDeclaredType: true,
2659
- type: types_1.FunctionType.getEffectiveParameterType(withoutParamSpec, index),
2660
- });
2694
+ const functionType = types_1.FunctionType.createInstance('', '', '', 65536 /* FunctionTypeFlags.ParamSpecValue */ | withoutParamSpec.shared.flags);
2695
+ types_1.FunctionType.addHigherOrderTypeVarScopeIds(functionType, withoutParamSpec.shared.typeVarScopeId);
2696
+ types_1.FunctionType.addHigherOrderTypeVarScopeIds(functionType, withoutParamSpec.priv.higherOrderTypeVarScopeIds);
2697
+ functionType.priv.constructorTypeVarScopeId = withoutParamSpec.priv.constructorTypeVarScopeId;
2698
+ withoutParamSpec.shared.parameters.forEach((entry, index) => {
2699
+ types_1.FunctionType.addParameter(functionType, types_1.FunctionParam.create(entry.category, types_1.FunctionType.getEffectiveParameterType(withoutParamSpec, index), (entry.flags & types_1.FunctionParamFlags.NameSynthesized) | types_1.FunctionParamFlags.TypeDeclared, entry.name, entry.defaultType));
2661
2700
  });
2662
2701
  if (paramSpec) {
2663
2702
  types_1.FunctionType.addParamSpecVariadics(functionType, paramSpec);
2664
2703
  }
2665
- functionType.details.docString = withoutParamSpec.details.docString;
2666
- functionType.details.deprecatedMessage = withoutParamSpec.details.deprecatedMessage;
2667
- functionType.details.methodClass = withoutParamSpec.details.methodClass;
2704
+ functionType.shared.docString = withoutParamSpec.shared.docString;
2705
+ functionType.shared.deprecatedMessage = withoutParamSpec.shared.deprecatedMessage;
2706
+ functionType.shared.methodClass = withoutParamSpec.shared.methodClass;
2668
2707
  return functionType;
2669
2708
  }
2670
2709
  exports.convertParamSpecValueToType = convertParamSpecValueToType;
@@ -2677,7 +2716,7 @@ class TypeVarTransformer {
2677
2716
  this._pendingFunctionTransformations = [];
2678
2717
  }
2679
2718
  apply(type, recursionCount) {
2680
- var _a, _b;
2719
+ var _a, _b, _c;
2681
2720
  if (recursionCount > types_1.maxTypeRecursionCount) {
2682
2721
  return type;
2683
2722
  }
@@ -2685,7 +2724,7 @@ class TypeVarTransformer {
2685
2724
  type = this.transformGenericTypeAlias(type, recursionCount);
2686
2725
  // If the type is conditioned on a type variable, see if the condition
2687
2726
  // still applies.
2688
- if (type.condition) {
2727
+ if ((_a = type.props) === null || _a === void 0 ? void 0 : _a.condition) {
2689
2728
  type = this.transformConditionalType(type, recursionCount);
2690
2729
  }
2691
2730
  // Shortcut the operation if possible.
@@ -2702,12 +2741,13 @@ class TypeVarTransformer {
2702
2741
  // Handle recursive type aliases specially. In particular,
2703
2742
  // we need to specialize type arguments for generic recursive
2704
2743
  // type aliases.
2705
- if (type.details.recursiveTypeAliasName) {
2706
- if (!((_a = type.typeAliasInfo) === null || _a === void 0 ? void 0 : _a.typeArguments)) {
2744
+ const aliasInfo = (_b = type.props) === null || _b === void 0 ? void 0 : _b.typeAliasInfo;
2745
+ if (type.shared.recursiveAlias) {
2746
+ if (!(aliasInfo === null || aliasInfo === void 0 ? void 0 : aliasInfo.typeArguments)) {
2707
2747
  return type;
2708
2748
  }
2709
2749
  let requiresUpdate = false;
2710
- const typeArgs = type.typeAliasInfo.typeArguments.map((typeArg) => {
2750
+ const typeArgs = aliasInfo.typeArguments.map((typeArg) => {
2711
2751
  const replacementType = this.apply(typeArg, recursionCount);
2712
2752
  if (replacementType !== typeArg) {
2713
2753
  requiresUpdate = true;
@@ -2715,7 +2755,7 @@ class TypeVarTransformer {
2715
2755
  return replacementType;
2716
2756
  });
2717
2757
  if (requiresUpdate) {
2718
- return types_1.TypeBase.cloneForTypeAlias(type, type.typeAliasInfo.name, type.typeAliasInfo.fullName, type.typeAliasInfo.moduleName, type.typeAliasInfo.fileUri, type.typeAliasInfo.typeVarScopeId, type.typeAliasInfo.isPep695Syntax, type.typeAliasInfo.typeParameters, typeArgs);
2758
+ return types_1.TypeBase.cloneForTypeAlias(type, aliasInfo.name, aliasInfo.fullName, aliasInfo.moduleName, aliasInfo.fileUri, aliasInfo.typeVarScopeId, aliasInfo.isPep695Syntax, aliasInfo.typeParameters, typeArgs);
2719
2759
  }
2720
2760
  return type;
2721
2761
  }
@@ -2723,18 +2763,18 @@ class TypeVarTransformer {
2723
2763
  // Recursively transform the results, but ensure that we don't replace any
2724
2764
  // type variables in the same scope recursively by setting it the scope in the
2725
2765
  // _pendingTypeVarTransformations set.
2726
- if (!this._isTypeVarScopePending(type.scopeId)) {
2727
- if (type.details.isParamSpec) {
2766
+ if (!this._isTypeVarScopePending(type.priv.scopeId)) {
2767
+ if (type.shared.isParamSpec) {
2728
2768
  let paramSpecWithoutAccess = type;
2729
- if (type.paramSpecAccess) {
2769
+ if (type.priv.paramSpecAccess) {
2730
2770
  paramSpecWithoutAccess = types_1.TypeVarType.cloneForParamSpecAccess(type, /* access */ undefined);
2731
2771
  }
2732
2772
  const paramSpecValue = this.transformParamSpec(paramSpecWithoutAccess, recursionCount);
2733
2773
  if (paramSpecValue) {
2734
2774
  const paramSpecType = convertParamSpecValueToType(paramSpecValue);
2735
- if (type.paramSpecAccess) {
2775
+ if (type.priv.paramSpecAccess) {
2736
2776
  if ((0, types_1.isParamSpec)(paramSpecType)) {
2737
- replacementType = types_1.TypeVarType.cloneForParamSpecAccess(paramSpecType, type.paramSpecAccess);
2777
+ replacementType = types_1.TypeVarType.cloneForParamSpecAccess(paramSpecType, type.priv.paramSpecAccess);
2738
2778
  }
2739
2779
  else {
2740
2780
  replacementType = types_1.UnknownType.create();
@@ -2746,19 +2786,19 @@ class TypeVarTransformer {
2746
2786
  }
2747
2787
  }
2748
2788
  else {
2749
- replacementType = (_b = this.transformTypeVar(type, recursionCount)) !== null && _b !== void 0 ? _b : type;
2789
+ replacementType = (_c = this.transformTypeVar(type, recursionCount)) !== null && _c !== void 0 ? _c : type;
2750
2790
  if (!this._isTransformingTypeArg) {
2751
- if (type.scopeId) {
2752
- this._pendingTypeVarTransformations.add(type.scopeId);
2791
+ if (type.priv.scopeId) {
2792
+ this._pendingTypeVarTransformations.add(type.priv.scopeId);
2753
2793
  }
2754
2794
  replacementType = this.apply(replacementType, recursionCount);
2755
- if (type.scopeId) {
2756
- this._pendingTypeVarTransformations.delete(type.scopeId);
2795
+ if (type.priv.scopeId) {
2796
+ this._pendingTypeVarTransformations.delete(type.priv.scopeId);
2757
2797
  }
2758
2798
  }
2759
2799
  // If we're transforming a variadic type variable that was in a union,
2760
2800
  // expand the union types.
2761
- if ((0, types_1.isVariadicTypeVar)(type) && type.isVariadicInUnion) {
2801
+ if ((0, types_1.isVariadicTypeVar)(type) && type.priv.isVariadicInUnion) {
2762
2802
  replacementType = _expandVariadicUnpackedUnion(replacementType);
2763
2803
  }
2764
2804
  }
@@ -2806,13 +2846,13 @@ class TypeVarTransformer {
2806
2846
  let requiresUpdate = false;
2807
2847
  // Specialize each of the functions in the overload.
2808
2848
  const newOverloads = [];
2809
- type.overloads.forEach((entry) => {
2849
+ type.priv.overloads.forEach((entry) => {
2810
2850
  const replacementType = this.transformTypeVarsInFunctionType(entry, recursionCount);
2811
2851
  if ((0, types_1.isFunction)(replacementType)) {
2812
2852
  newOverloads.push(replacementType);
2813
2853
  }
2814
2854
  else {
2815
- (0, collectionUtils_1.appendArray)(newOverloads, replacementType.overloads);
2855
+ (0, collectionUtils_1.appendArray)(newOverloads, replacementType.priv.overloads);
2816
2856
  }
2817
2857
  if (replacementType !== entry) {
2818
2858
  requiresUpdate = true;
@@ -2842,11 +2882,13 @@ class TypeVarTransformer {
2842
2882
  return callback();
2843
2883
  }
2844
2884
  transformGenericTypeAlias(type, recursionCount) {
2845
- if (!type.typeAliasInfo || !type.typeAliasInfo.typeParameters || !type.typeAliasInfo.typeArguments) {
2885
+ var _a;
2886
+ const aliasInfo = (_a = type.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo;
2887
+ if (!aliasInfo || !aliasInfo.typeParameters || !aliasInfo.typeArguments) {
2846
2888
  return type;
2847
2889
  }
2848
2890
  let requiresUpdate = false;
2849
- const newTypeArgs = type.typeAliasInfo.typeArguments.map((typeArg) => {
2891
+ const newTypeArgs = aliasInfo.typeArguments.map((typeArg) => {
2850
2892
  const updatedType = this.apply(typeArg, recursionCount);
2851
2893
  if (type !== updatedType) {
2852
2894
  requiresUpdate = true;
@@ -2854,7 +2896,7 @@ class TypeVarTransformer {
2854
2896
  return updatedType;
2855
2897
  });
2856
2898
  return requiresUpdate
2857
- ? types_1.TypeBase.cloneForTypeAlias(type, type.typeAliasInfo.name, type.typeAliasInfo.fullName, type.typeAliasInfo.moduleName, type.typeAliasInfo.fileUri, type.typeAliasInfo.typeVarScopeId, type.typeAliasInfo.isPep695Syntax, type.typeAliasInfo.typeParameters, newTypeArgs)
2899
+ ? types_1.TypeBase.cloneForTypeAlias(type, aliasInfo.name, aliasInfo.fullName, aliasInfo.moduleName, aliasInfo.fileUri, aliasInfo.typeVarScopeId, aliasInfo.isPep695Syntax, aliasInfo.typeParameters, newTypeArgs)
2858
2900
  : type;
2859
2901
  }
2860
2902
  transformConditionalType(type, recursionCount) {
@@ -2887,9 +2929,9 @@ class TypeVarTransformer {
2887
2929
  // If type args were previously provided, specialize them.
2888
2930
  // Handle tuples specially.
2889
2931
  if (types_1.ClassType.isTupleClass(classType)) {
2890
- if (classType.tupleTypeArguments) {
2932
+ if (classType.priv.tupleTypeArguments) {
2891
2933
  newTupleTypeArgs = [];
2892
- classType.tupleTypeArguments.forEach((oldTypeArgType) => {
2934
+ classType.priv.tupleTypeArguments.forEach((oldTypeArgType) => {
2893
2935
  const newTypeArgType = this.apply(oldTypeArgType.type, recursionCount);
2894
2936
  if (newTypeArgType !== oldTypeArgType.type) {
2895
2937
  specializationNeeded = true;
@@ -2897,8 +2939,8 @@ class TypeVarTransformer {
2897
2939
  if ((0, types_1.isUnpackedVariadicTypeVar)(oldTypeArgType.type) &&
2898
2940
  (0, types_1.isClassInstance)(newTypeArgType) &&
2899
2941
  isTupleClass(newTypeArgType) &&
2900
- newTypeArgType.tupleTypeArguments) {
2901
- (0, collectionUtils_1.appendArray)(newTupleTypeArgs, newTypeArgType.tupleTypeArguments);
2942
+ newTypeArgType.priv.tupleTypeArguments) {
2943
+ (0, collectionUtils_1.appendArray)(newTupleTypeArgs, newTypeArgType.priv.tupleTypeArguments);
2902
2944
  }
2903
2945
  else {
2904
2946
  // Handle the special case where tuple[T, ...] is being specialized
@@ -2906,7 +2948,7 @@ class TypeVarTransformer {
2906
2948
  const isEmptyTuple = oldTypeArgType.isUnbounded &&
2907
2949
  (0, types_1.isTypeVar)(oldTypeArgType.type) &&
2908
2950
  (0, types_1.isNever)(newTypeArgType) &&
2909
- classType.tupleTypeArguments.length === 1;
2951
+ classType.priv.tupleTypeArguments.length === 1;
2910
2952
  if (!isEmptyTuple) {
2911
2953
  newTupleTypeArgs.push({
2912
2954
  type: newTypeArgType,
@@ -2943,9 +2985,9 @@ class TypeVarTransformer {
2943
2985
  }
2944
2986
  }
2945
2987
  if (!newTypeArgs) {
2946
- if (classType.typeArguments) {
2947
- newTypeArgs = classType.typeArguments.map((oldTypeArgType) => {
2948
- if ((0, types_1.isTypeVar)(oldTypeArgType) && oldTypeArgType.details.isParamSpec) {
2988
+ if (classType.priv.typeArguments) {
2989
+ newTypeArgs = classType.priv.typeArguments.map((oldTypeArgType) => {
2990
+ if ((0, types_1.isTypeVar)(oldTypeArgType) && oldTypeArgType.shared.isParamSpec) {
2949
2991
  return transformParamSpec(oldTypeArgType);
2950
2992
  }
2951
2993
  let newTypeArgType = this.apply(oldTypeArgType, recursionCount);
@@ -2955,7 +2997,7 @@ class TypeVarTransformer {
2955
2997
  // (e.g. Union[Unpack[Vs]]), expand the subtypes into a union here.
2956
2998
  if ((0, types_1.isTypeVar)(oldTypeArgType) &&
2957
2999
  (0, types_1.isVariadicTypeVar)(oldTypeArgType) &&
2958
- oldTypeArgType.isVariadicInUnion) {
3000
+ oldTypeArgType.priv.isVariadicInUnion) {
2959
3001
  newTypeArgType = _expandVariadicUnpackedUnion(newTypeArgType);
2960
3002
  }
2961
3003
  }
@@ -2966,20 +3008,20 @@ class TypeVarTransformer {
2966
3008
  newTypeArgs = [];
2967
3009
  typeParams.forEach((typeParam) => {
2968
3010
  let replacementType = typeParam;
2969
- if (typeParam.details.isParamSpec) {
3011
+ if (typeParam.shared.isParamSpec) {
2970
3012
  replacementType = transformParamSpec(typeParam);
2971
3013
  if (replacementType !== typeParam) {
2972
3014
  specializationNeeded = true;
2973
3015
  }
2974
3016
  }
2975
3017
  else {
2976
- if (!this._isTypeVarScopePending(typeParam.scopeId)) {
3018
+ if (!this._isTypeVarScopePending(typeParam.priv.scopeId)) {
2977
3019
  const transformedType = this.transformTypeVar(typeParam, recursionCount);
2978
3020
  replacementType = transformedType !== null && transformedType !== void 0 ? transformedType : typeParam;
2979
3021
  if (replacementType !== typeParam) {
2980
3022
  specializationNeeded = true;
2981
3023
  }
2982
- else if (transformedType !== undefined && !classType.typeArguments) {
3024
+ else if (transformedType !== undefined && !classType.priv.typeArguments) {
2983
3025
  specializationNeeded = true;
2984
3026
  }
2985
3027
  }
@@ -3007,6 +3049,7 @@ class TypeVarTransformer {
3007
3049
  let typesRequiredSpecialization = declaredReturnType !== specializedReturnType;
3008
3050
  const specializedParameters = {
3009
3051
  parameterTypes: [],
3052
+ parameterDefaultArgs: undefined,
3010
3053
  returnType: specializedReturnType,
3011
3054
  };
3012
3055
  const paramSpec = types_1.FunctionType.getParamSpecFromArgsKwargs(functionType);
@@ -3014,7 +3057,7 @@ class TypeVarTransformer {
3014
3057
  const paramSpecType = this.transformParamSpec(paramSpec, recursionCount);
3015
3058
  if (paramSpecType) {
3016
3059
  const transformedParamSpec = types_1.FunctionType.getParamSpecFromArgsKwargs(paramSpecType);
3017
- if (paramSpecType.details.parameters.length > 0 ||
3060
+ if (paramSpecType.shared.parameters.length > 0 ||
3018
3061
  !transformedParamSpec ||
3019
3062
  !(0, types_1.isTypeSame)(paramSpec, transformedParamSpec)) {
3020
3063
  functionType = types_1.FunctionType.applyParamSpecValue(functionType, paramSpecType);
@@ -3026,7 +3069,7 @@ class TypeVarTransformer {
3026
3069
  const specializedDefaultArgs = [];
3027
3070
  const wasTransformingTypeArg = this._isTransformingTypeArg;
3028
3071
  this._isTransformingTypeArg = true;
3029
- for (let i = 0; i < functionType.details.parameters.length; i++) {
3072
+ for (let i = 0; i < functionType.shared.parameters.length; i++) {
3030
3073
  const paramType = types_1.FunctionType.getEffectiveParameterType(functionType, i);
3031
3074
  const specializedType = this.apply(paramType, recursionCount);
3032
3075
  specializedParameters.parameterTypes.push(specializedType);
@@ -3042,12 +3085,12 @@ class TypeVarTransformer {
3042
3085
  specializedDefaultArgs.push(defaultArgType);
3043
3086
  if (variadicParamIndex === undefined &&
3044
3087
  (0, types_1.isVariadicTypeVar)(paramType) &&
3045
- functionType.details.parameters[i].category === 1 /* ParameterCategory.ArgsList */) {
3088
+ functionType.shared.parameters[i].category === 1 /* ParameterCategory.ArgsList */) {
3046
3089
  variadicParamIndex = i;
3047
3090
  if ((0, types_1.isClassInstance)(specializedType) &&
3048
3091
  isTupleClass(specializedType) &&
3049
- specializedType.isUnpacked) {
3050
- variadicTypesToUnpack = specializedType.tupleTypeArguments;
3092
+ specializedType.priv.isUnpacked) {
3093
+ variadicTypesToUnpack = specializedType.priv.tupleTypeArguments;
3051
3094
  }
3052
3095
  }
3053
3096
  if (paramType !== specializedType) {
@@ -3055,12 +3098,27 @@ class TypeVarTransformer {
3055
3098
  }
3056
3099
  }
3057
3100
  let specializedInferredReturnType;
3058
- if (functionType.inferredReturnType) {
3059
- specializedInferredReturnType = this.apply(functionType.inferredReturnType, recursionCount);
3060
- if (specializedInferredReturnType !== functionType.inferredReturnType) {
3101
+ if (functionType.priv.inferredReturnType) {
3102
+ specializedInferredReturnType = this.apply(functionType.priv.inferredReturnType, recursionCount);
3103
+ if (specializedInferredReturnType !== functionType.priv.inferredReturnType) {
3061
3104
  typesRequiredSpecialization = true;
3062
3105
  }
3063
3106
  }
3107
+ // Do we need to update the boundToType?
3108
+ if (functionType.priv.boundToType) {
3109
+ const newBoundToType = this.apply(functionType.priv.boundToType, recursionCount);
3110
+ if (newBoundToType !== functionType.priv.boundToType && (0, types_1.isClass)(newBoundToType)) {
3111
+ functionType = types_1.FunctionType.clone(functionType, /* stripFirstParam */ false, newBoundToType);
3112
+ }
3113
+ }
3114
+ // Do we need to update the strippedFirstParamType?
3115
+ if (functionType.priv.strippedFirstParamType) {
3116
+ const newStrippedType = this.apply(functionType.priv.strippedFirstParamType, recursionCount);
3117
+ if (newStrippedType !== functionType.priv.strippedFirstParamType) {
3118
+ functionType = types_1.TypeBase.cloneType(functionType);
3119
+ functionType.priv.strippedFirstParamType = newStrippedType;
3120
+ }
3121
+ }
3064
3122
  this._isTransformingTypeArg = wasTransformingTypeArg;
3065
3123
  if (!typesRequiredSpecialization) {
3066
3124
  return functionType;
@@ -3074,8 +3132,8 @@ class TypeVarTransformer {
3074
3132
  }
3075
3133
  // Unpack the tuple and synthesize a new function in the process.
3076
3134
  const newFunctionType = types_1.TypeBase.isInstantiable(functionType)
3077
- ? types_1.FunctionType.createInstantiable(functionType.details.flags | 64 /* FunctionTypeFlags.SynthesizedMethod */)
3078
- : types_1.FunctionType.createSynthesizedInstance('', functionType.details.flags);
3135
+ ? types_1.FunctionType.createInstantiable(functionType.shared.flags | 64 /* FunctionTypeFlags.SynthesizedMethod */)
3136
+ : types_1.FunctionType.createSynthesizedInstance('', functionType.shared.flags);
3079
3137
  let insertKeywordOnlySeparator = false;
3080
3138
  let swallowPositionOnlySeparator = false;
3081
3139
  specializedParameters.parameterTypes.forEach((paramType, index) => {
@@ -3083,15 +3141,9 @@ class TypeVarTransformer {
3083
3141
  let sawUnboundedEntry = false;
3084
3142
  // Unpack the tuple into individual parameters.
3085
3143
  variadicTypesToUnpack.forEach((unpackedType) => {
3086
- types_1.FunctionType.addParameter(newFunctionType, {
3087
- category: unpackedType.isUnbounded || (0, types_1.isVariadicTypeVar)(unpackedType.type)
3088
- ? 1 /* ParameterCategory.ArgsList */
3089
- : 0 /* ParameterCategory.Simple */,
3090
- name: `__p${newFunctionType.details.parameters.length}`,
3091
- isNameSynthesized: true,
3092
- type: unpackedType.type,
3093
- hasDeclaredType: true,
3094
- });
3144
+ types_1.FunctionType.addParameter(newFunctionType, types_1.FunctionParam.create(unpackedType.isUnbounded || (0, types_1.isVariadicTypeVar)(unpackedType.type)
3145
+ ? 1 /* ParameterCategory.ArgsList */
3146
+ : 0 /* ParameterCategory.Simple */, unpackedType.type, types_1.FunctionParamFlags.NameSynthesized | types_1.FunctionParamFlags.TypeDeclared, `__p${newFunctionType.shared.parameters.length}`));
3095
3147
  if (unpackedType.isUnbounded) {
3096
3148
  sawUnboundedEntry = true;
3097
3149
  }
@@ -3104,7 +3156,7 @@ class TypeVarTransformer {
3104
3156
  }
3105
3157
  }
3106
3158
  else {
3107
- const param = { ...functionType.details.parameters[index] };
3159
+ const param = { ...functionType.shared.parameters[index] };
3108
3160
  if ((0, types_1.isKeywordOnlySeparator)(param)) {
3109
3161
  insertKeywordOnlySeparator = false;
3110
3162
  }
@@ -3118,15 +3170,15 @@ class TypeVarTransformer {
3118
3170
  insertKeywordOnlySeparator = false;
3119
3171
  }
3120
3172
  param.type = paramType;
3121
- if (param.name && param.isNameSynthesized) {
3122
- param.name = `__p${newFunctionType.details.parameters.length}`;
3173
+ if (param.name && types_1.FunctionParam.isNameSynthesized(param)) {
3174
+ param.name = `__p${newFunctionType.shared.parameters.length}`;
3123
3175
  }
3124
3176
  if (param.category !== 0 /* ParameterCategory.Simple */ || param.name || !swallowPositionOnlySeparator) {
3125
3177
  types_1.FunctionType.addParameter(newFunctionType, param);
3126
3178
  }
3127
3179
  }
3128
3180
  });
3129
- newFunctionType.details.declaredReturnType = specializedParameters.returnType;
3181
+ newFunctionType.shared.declaredReturnType = specializedParameters.returnType;
3130
3182
  return newFunctionType;
3131
3183
  });
3132
3184
  }
@@ -3155,16 +3207,16 @@ class TypeVarDefaultValidator extends TypeVarTransformer {
3155
3207
  this._invalidTypeVars = _invalidTypeVars;
3156
3208
  }
3157
3209
  transformTypeVar(typeVar) {
3158
- const replacementType = this._liveTypeParams.find((param) => param.details.name === typeVar.details.name);
3210
+ const replacementType = this._liveTypeParams.find((param) => param.shared.name === typeVar.shared.name);
3159
3211
  if (!replacementType || (0, types_1.isParamSpec)(replacementType)) {
3160
- this._invalidTypeVars.add(typeVar.details.name);
3212
+ this._invalidTypeVars.add(typeVar.shared.name);
3161
3213
  }
3162
3214
  return types_1.UnknownType.create();
3163
3215
  }
3164
3216
  transformParamSpec(paramSpec) {
3165
- const replacementType = this._liveTypeParams.find((param) => param.details.name === paramSpec.details.name);
3217
+ const replacementType = this._liveTypeParams.find((param) => param.shared.name === paramSpec.shared.name);
3166
3218
  if (!replacementType || !(0, types_1.isParamSpec)(replacementType)) {
3167
- this._invalidTypeVars.add(paramSpec.details.name);
3219
+ this._invalidTypeVars.add(paramSpec.shared.name);
3168
3220
  }
3169
3221
  return undefined;
3170
3222
  }
@@ -3184,11 +3236,11 @@ class UniqueFunctionSignatureTransformer extends TypeVarTransformer {
3184
3236
  return classType;
3185
3237
  }
3186
3238
  transformTypeVarsInFunctionType(sourceType, recursionCount) {
3187
- if (sourceType.trackedSignatures) {
3188
- this._signatureTracker.addTrackedSignatures(sourceType.trackedSignatures);
3239
+ if (sourceType.priv.trackedSignatures) {
3240
+ this._signatureTracker.addTrackedSignatures(sourceType.priv.trackedSignatures);
3189
3241
  }
3190
3242
  // If this function is not generic, there's no need to check for uniqueness.
3191
- if (sourceType.details.typeParameters.length === 0) {
3243
+ if (sourceType.shared.typeParameters.length === 0) {
3192
3244
  return super.transformTypeVarsInFunctionType(sourceType, recursionCount);
3193
3245
  }
3194
3246
  let updatedSourceType = sourceType;
@@ -3202,10 +3254,10 @@ class UniqueFunctionSignatureTransformer extends TypeVarTransformer {
3202
3254
  const typeVarContext = new typeVarContext_1.TypeVarContext(getTypeVarScopeIds(sourceType));
3203
3255
  // Create new type variables with the same scope but with
3204
3256
  // different (unique) names.
3205
- sourceType.details.typeParameters.forEach((typeParam) => {
3206
- if (typeParam.scopeType === 1 /* TypeVarScopeType.Function */) {
3207
- let replacement = types_1.TypeVarType.cloneForNewName(typeParam, `${typeParam.details.name}(${offsetIndex})`);
3208
- if (replacement.details.isParamSpec) {
3257
+ sourceType.shared.typeParameters.forEach((typeParam) => {
3258
+ if (typeParam.priv.scopeType === 1 /* TypeVarScopeType.Function */) {
3259
+ let replacement = types_1.TypeVarType.cloneForNewName(typeParam, `${typeParam.shared.name}(${offsetIndex})`);
3260
+ if (replacement.shared.isParamSpec) {
3209
3261
  replacement = convertTypeToParamSpecValue(replacement);
3210
3262
  }
3211
3263
  typeVarContext.setTypeVarType(typeParam, replacement);
@@ -3233,7 +3285,7 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
3233
3285
  const signatureContext = this._typeVarContext.getSignatureContext((_a = this._activeTypeVarSignatureContextIndex) !== null && _a !== void 0 ? _a : 0);
3234
3286
  // If the type variable is unrelated to the scopes we're solving,
3235
3287
  // don't transform that type variable.
3236
- if (typeVar.scopeId && this._typeVarContext.hasSolveForScope(typeVar.scopeId)) {
3288
+ if (typeVar.priv.scopeId && this._typeVarContext.hasSolveForScope(typeVar.priv.scopeId)) {
3237
3289
  let replacement = signatureContext.getTypeVarType(typeVar, !!this._options.useNarrowBoundOnly);
3238
3290
  // If there was no narrow bound but there is a wide bound that
3239
3291
  // contains literals or a TypeVar, we'll use the wide bound even if
@@ -3267,22 +3319,24 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
3267
3319
  if ((0, types_1.isClassInstance)(subtype)) {
3268
3320
  // If the includeSubclasses wasn't set, force it to be set by
3269
3321
  // converting to/from an instantiable.
3270
- if (!subtype.includeSubclasses) {
3322
+ if (!subtype.priv.includeSubclasses) {
3271
3323
  subtype = types_1.ClassType.cloneAsInstance(types_1.ClassType.cloneAsInstantiable(subtype));
3272
3324
  }
3273
3325
  if (this._options.unknownIfNotFound) {
3274
3326
  return this._options.useUnknownOverDefault
3275
- ? specializeWithUnknownTypeArgs(subtype)
3327
+ ? specializeWithUnknownTypeArgs(subtype, this._options.tupleClassType)
3276
3328
  : specializeWithDefaultTypeArgs(subtype);
3277
3329
  }
3278
3330
  }
3279
3331
  return subtype;
3280
3332
  });
3281
3333
  }
3282
- if ((0, types_1.isTypeVar)(replacement) && typeVar.isVariadicUnpacked && replacement.details.isVariadic) {
3283
- return types_1.TypeVarType.cloneForUnpacked(replacement, typeVar.isVariadicInUnion);
3334
+ if ((0, types_1.isTypeVar)(replacement) && typeVar.priv.isVariadicUnpacked && replacement.shared.isVariadic) {
3335
+ return types_1.TypeVarType.cloneForUnpacked(replacement, typeVar.priv.isVariadicInUnion);
3284
3336
  }
3285
- if (!(0, types_1.isTypeVar)(replacement) || !replacement.isInScopePlaceholder || !this._options.unknownIfNotFound) {
3337
+ if (!(0, types_1.isTypeVar)(replacement) ||
3338
+ !replacement.priv.isInScopePlaceholder ||
3339
+ !this._options.unknownIfNotFound) {
3286
3340
  return replacement;
3287
3341
  }
3288
3342
  }
@@ -3297,27 +3351,27 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
3297
3351
  useDefaultOrUnknown = true;
3298
3352
  }
3299
3353
  }
3300
- else if (this._options.applyInScopePlaceholders && typeVar.isInScopePlaceholder) {
3354
+ else if (this._options.applyInScopePlaceholders && typeVar.priv.isInScopePlaceholder) {
3301
3355
  useDefaultOrUnknown = true;
3302
3356
  }
3303
3357
  if (useDefaultOrUnknown) {
3304
3358
  // Use the default value if there is one.
3305
- if (typeVar.details.isDefaultExplicit && !this._options.useUnknownOverDefault) {
3306
- return this._solveDefaultType(typeVar.details.defaultType, recursionCount);
3359
+ if (typeVar.shared.isDefaultExplicit && !this._options.useUnknownOverDefault) {
3360
+ return this._solveDefaultType(typeVar.shared.defaultType, recursionCount);
3307
3361
  }
3308
- return types_1.UnknownType.create();
3362
+ return getUnknownTypeForTypeVar(typeVar, this._options.tupleClassType);
3309
3363
  }
3310
3364
  }
3311
3365
  // If we're solving a default type, handle type variables with no scope ID.
3312
- if (this._isSolvingDefaultType && !typeVar.scopeId) {
3366
+ if (this._isSolvingDefaultType && !typeVar.priv.scopeId) {
3313
3367
  const replacementEntry = signatureContext
3314
3368
  .getTypeVars()
3315
- .find((entry) => entry.typeVar.details.name === typeVar.details.name);
3369
+ .find((entry) => entry.typeVar.shared.name === typeVar.shared.name);
3316
3370
  if (replacementEntry) {
3317
3371
  return signatureContext.getTypeVarType(replacementEntry.typeVar);
3318
3372
  }
3319
- if (typeVar.details.isDefaultExplicit) {
3320
- return this.apply(typeVar.details.defaultType, recursionCount);
3373
+ if (typeVar.shared.isDefaultExplicit) {
3374
+ return this.apply(typeVar.shared.defaultType, recursionCount);
3321
3375
  }
3322
3376
  return types_1.UnknownType.create();
3323
3377
  }
@@ -3332,12 +3386,12 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
3332
3386
  // def test(x: Union[str, T]) -> Union[str, T]
3333
3387
  if (this._options.eliminateUnsolvedInUnions) {
3334
3388
  if ((0, types_1.isTypeVar)(preTransform) &&
3335
- preTransform.scopeId !== undefined &&
3336
- this._typeVarContext.hasSolveForScope(preTransform.scopeId)) {
3389
+ preTransform.priv.scopeId !== undefined &&
3390
+ this._typeVarContext.hasSolveForScope(preTransform.priv.scopeId)) {
3337
3391
  const signatureContext = this._typeVarContext.getSignatureContext((_a = this._activeTypeVarSignatureContextIndex) !== null && _a !== void 0 ? _a : 0);
3338
3392
  const typeVarType = signatureContext.getTypeVarType(preTransform);
3339
3393
  // Did the TypeVar remain unsolved?
3340
- if (!typeVarType || ((0, types_1.isTypeVar)(typeVarType) && typeVarType.isInScopePlaceholder)) {
3394
+ if (!typeVarType || ((0, types_1.isTypeVar)(typeVarType) && typeVarType.priv.isInScopePlaceholder)) {
3341
3395
  // If the TypeVar was not transformed, then it was unsolved,
3342
3396
  // and we'll eliminate it.
3343
3397
  if (preTransform === postTransform) {
@@ -3355,10 +3409,12 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
3355
3409
  }
3356
3410
  transformTupleTypeVar(typeVar) {
3357
3411
  var _a;
3358
- if (!typeVar.scopeId || !this._typeVarContext.hasSolveForScope(typeVar.scopeId)) {
3359
- const defaultType = typeVar.details.defaultType;
3360
- if (typeVar.details.isDefaultExplicit && (0, types_1.isClassInstance)(defaultType) && defaultType.tupleTypeArguments) {
3361
- return defaultType.tupleTypeArguments;
3412
+ if (!typeVar.priv.scopeId || !this._typeVarContext.hasSolveForScope(typeVar.priv.scopeId)) {
3413
+ const defaultType = typeVar.shared.defaultType;
3414
+ if (typeVar.shared.isDefaultExplicit &&
3415
+ (0, types_1.isClassInstance)(defaultType) &&
3416
+ defaultType.priv.tupleTypeArguments) {
3417
+ return defaultType.priv.tupleTypeArguments;
3362
3418
  }
3363
3419
  return undefined;
3364
3420
  }
@@ -3369,19 +3425,19 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
3369
3425
  var _a, _b;
3370
3426
  const signatureContext = this._typeVarContext.getSignatureContext((_a = this._activeTypeVarSignatureContextIndex) !== null && _a !== void 0 ? _a : 0);
3371
3427
  // If we're solving a default type, handle param specs with no scope ID.
3372
- if (this._isSolvingDefaultType && !paramSpec.scopeId) {
3428
+ if (this._isSolvingDefaultType && !paramSpec.priv.scopeId) {
3373
3429
  const replacementEntry = signatureContext
3374
3430
  .getTypeVars()
3375
- .find((entry) => entry.typeVar.details.name === paramSpec.details.name);
3431
+ .find((entry) => entry.typeVar.shared.name === paramSpec.shared.name);
3376
3432
  if (replacementEntry) {
3377
3433
  return signatureContext.getParamSpecType(replacementEntry.typeVar);
3378
3434
  }
3379
- if (paramSpec.details.isDefaultExplicit) {
3380
- return convertTypeToParamSpecValue(this.apply(paramSpec.details.defaultType, recursionCount));
3435
+ if (paramSpec.shared.isDefaultExplicit) {
3436
+ return convertTypeToParamSpecValue(this.apply(paramSpec.shared.defaultType, recursionCount));
3381
3437
  }
3382
3438
  return getUnknownTypeForParamSpec();
3383
3439
  }
3384
- if (!paramSpec.scopeId || !this._typeVarContext.hasSolveForScope(paramSpec.scopeId)) {
3440
+ if (!paramSpec.priv.scopeId || !this._typeVarContext.hasSolveForScope(paramSpec.priv.scopeId)) {
3385
3441
  return undefined;
3386
3442
  }
3387
3443
  const transformedParamSpec = signatureContext.getParamSpecType(paramSpec);
@@ -3395,13 +3451,13 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
3395
3451
  useDefaultOrUnknown = true;
3396
3452
  }
3397
3453
  }
3398
- else if (this._options.applyInScopePlaceholders && paramSpec.isInScopePlaceholder) {
3454
+ else if (this._options.applyInScopePlaceholders && paramSpec.priv.isInScopePlaceholder) {
3399
3455
  useDefaultOrUnknown = true;
3400
3456
  }
3401
3457
  if (useDefaultOrUnknown) {
3402
3458
  // Use the default value if there is one.
3403
- if (paramSpec.details.isDefaultExplicit && !this._options.useUnknownOverDefault) {
3404
- return convertTypeToParamSpecValue(this._solveDefaultType(paramSpec.details.defaultType, recursionCount));
3459
+ if (paramSpec.shared.isDefaultExplicit && !this._options.useUnknownOverDefault) {
3460
+ return convertTypeToParamSpecValue(this._solveDefaultType(paramSpec.shared.defaultType, recursionCount));
3405
3461
  }
3406
3462
  // Convert to the ParamSpec equivalent of "Unknown".
3407
3463
  return getUnknownTypeForParamSpec();
@@ -3409,25 +3465,25 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
3409
3465
  return undefined;
3410
3466
  }
3411
3467
  transformConditionalType(type, recursionCount) {
3412
- var _a;
3413
- if (!type.condition) {
3468
+ var _a, _b;
3469
+ if (!((_a = type.props) === null || _a === void 0 ? void 0 : _a.condition)) {
3414
3470
  return type;
3415
3471
  }
3416
- const signatureContext = this._typeVarContext.getSignatureContext((_a = this._activeTypeVarSignatureContextIndex) !== null && _a !== void 0 ? _a : 0);
3417
- for (const condition of type.condition) {
3472
+ const signatureContext = this._typeVarContext.getSignatureContext((_b = this._activeTypeVarSignatureContextIndex) !== null && _b !== void 0 ? _b : 0);
3473
+ for (const condition of type.props.condition) {
3418
3474
  // This doesn't apply to bound type variables.
3419
- if (condition.typeVar.details.constraints.length === 0) {
3475
+ if (condition.typeVar.shared.constraints.length === 0) {
3420
3476
  continue;
3421
3477
  }
3422
3478
  const typeVarEntry = signatureContext.getTypeVar(condition.typeVar);
3423
- if (!typeVarEntry || condition.constraintIndex >= typeVarEntry.typeVar.details.constraints.length) {
3479
+ if (!typeVarEntry || condition.constraintIndex >= typeVarEntry.typeVar.shared.constraints.length) {
3424
3480
  continue;
3425
3481
  }
3426
3482
  const value = signatureContext.getTypeVarType(typeVarEntry.typeVar);
3427
3483
  if (!value) {
3428
3484
  continue;
3429
3485
  }
3430
- const constraintType = typeVarEntry.typeVar.details.constraints[condition.constraintIndex];
3486
+ const constraintType = typeVarEntry.typeVar.shared.constraints[condition.constraintIndex];
3431
3487
  // If this violates the constraint, substitute a Never type.
3432
3488
  if (!(0, types_1.isTypeSame)(constraintType, value)) {
3433
3489
  return types_1.NeverType.createNever();
@@ -3451,7 +3507,7 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
3451
3507
  const filteredOverloads = [];
3452
3508
  doForEachSubtype((0, types_1.combineTypes)(overloadTypes), (subtype) => {
3453
3509
  (0, debug_1.assert)((0, types_1.isFunction)(subtype));
3454
- subtype = types_1.FunctionType.cloneWithNewFlags(subtype, subtype.details.flags | 256 /* FunctionTypeFlags.Overloaded */);
3510
+ subtype = types_1.FunctionType.cloneWithNewFlags(subtype, subtype.shared.flags | 256 /* FunctionTypeFlags.Overloaded */);
3455
3511
  filteredOverloads.push(subtype);
3456
3512
  });
3457
3513
  if (filteredOverloads.length === 1) {
@@ -3486,7 +3542,7 @@ class ExpectedTypeTransformer extends TypeVarTransformer {
3486
3542
  return undefined;
3487
3543
  }
3488
3544
  _isTypeVarLive(typeVar) {
3489
- return this._liveTypeVarScopes.some((scopeId) => typeVar.scopeId === scopeId);
3545
+ return this._liveTypeVarScopes.some((scopeId) => typeVar.priv.scopeId === scopeId);
3490
3546
  }
3491
3547
  }
3492
3548
  class InScopePlaceholderTransformer extends TypeVarTransformer {
@@ -3496,13 +3552,13 @@ class InScopePlaceholderTransformer extends TypeVarTransformer {
3496
3552
  }
3497
3553
  transformTypeVar(typeVar) {
3498
3554
  var _a;
3499
- if (typeVar.isInScopePlaceholder) {
3555
+ if (typeVar.priv.isInScopePlaceholder) {
3500
3556
  return (_a = this._signatureContext.getTypeVarType(typeVar)) !== null && _a !== void 0 ? _a : typeVar;
3501
3557
  }
3502
3558
  return typeVar;
3503
3559
  }
3504
3560
  transformParamSpec(paramSpec) {
3505
- if (paramSpec.isInScopePlaceholder) {
3561
+ if (paramSpec.priv.isInScopePlaceholder) {
3506
3562
  return this._signatureContext.getParamSpecType(paramSpec);
3507
3563
  }
3508
3564
  return undefined;
@@ -3511,7 +3567,7 @@ class InScopePlaceholderTransformer extends TypeVarTransformer {
3511
3567
  function applyInScopePlaceholdersToType(type, signatureContext) {
3512
3568
  // Handle the common case where there are no in-scope placeholders.
3513
3569
  // No more work is required in this case.
3514
- if (!signatureContext.getTypeVars().some((entry) => entry.typeVar.isInScopePlaceholder)) {
3570
+ if (!signatureContext.getTypeVars().some((entry) => entry.typeVar.priv.isInScopePlaceholder)) {
3515
3571
  return type;
3516
3572
  }
3517
3573
  const transformer = new InScopePlaceholderTransformer(signatureContext);