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

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 (211) hide show
  1. package/dist/analyzer/analyzerNodeInfo.js +2 -2
  2. package/dist/analyzer/analyzerNodeInfo.js.map +1 -1
  3. package/dist/analyzer/binder.js +8 -8
  4. package/dist/analyzer/binder.js.map +1 -1
  5. package/dist/analyzer/cacheManager.js +3 -0
  6. package/dist/analyzer/cacheManager.js.map +1 -1
  7. package/dist/analyzer/checker.d.ts +3 -2
  8. package/dist/analyzer/checker.js +115 -122
  9. package/dist/analyzer/checker.js.map +1 -1
  10. package/dist/analyzer/codeFlowEngine.d.ts +2 -2
  11. package/dist/analyzer/codeFlowEngine.js +49 -42
  12. package/dist/analyzer/codeFlowEngine.js.map +1 -1
  13. package/dist/analyzer/codeFlowTypes.js +1 -1
  14. package/dist/analyzer/codeFlowTypes.js.map +1 -1
  15. package/dist/analyzer/constraintSolver.d.ts +2 -2
  16. package/dist/analyzer/constraintSolver.js +164 -204
  17. package/dist/analyzer/constraintSolver.js.map +1 -1
  18. package/dist/analyzer/constructorTransform.d.ts +2 -2
  19. package/dist/analyzer/constructorTransform.js +15 -15
  20. package/dist/analyzer/constructorTransform.js.map +1 -1
  21. package/dist/analyzer/constructors.d.ts +2 -2
  22. package/dist/analyzer/constructors.js +28 -33
  23. package/dist/analyzer/constructors.js.map +1 -1
  24. package/dist/analyzer/dataClasses.d.ts +2 -2
  25. package/dist/analyzer/dataClasses.js +59 -36
  26. package/dist/analyzer/dataClasses.js.map +1 -1
  27. package/dist/analyzer/declaration.d.ts +9 -9
  28. package/dist/analyzer/declaration.js +9 -9
  29. package/dist/analyzer/declaration.js.map +1 -1
  30. package/dist/analyzer/declarationUtils.d.ts +1 -1
  31. package/dist/analyzer/declarationUtils.js +6 -6
  32. package/dist/analyzer/declarationUtils.js.map +1 -1
  33. package/dist/analyzer/decorators.js +4 -4
  34. package/dist/analyzer/decorators.js.map +1 -1
  35. package/dist/analyzer/docStringConversion.js +2 -2
  36. package/dist/analyzer/docStringConversion.js.map +1 -1
  37. package/dist/analyzer/enums.d.ts +2 -2
  38. package/dist/analyzer/enums.js +6 -6
  39. package/dist/analyzer/enums.js.map +1 -1
  40. package/dist/analyzer/functionTransform.d.ts +2 -2
  41. package/dist/analyzer/functionTransform.js +4 -4
  42. package/dist/analyzer/functionTransform.js.map +1 -1
  43. package/dist/analyzer/importResolver.js +5 -3
  44. package/dist/analyzer/importResolver.js.map +1 -1
  45. package/dist/analyzer/namedTuples.d.ts +3 -3
  46. package/dist/analyzer/namedTuples.js +21 -22
  47. package/dist/analyzer/namedTuples.js.map +1 -1
  48. package/dist/analyzer/operations.js +10 -10
  49. package/dist/analyzer/operations.js.map +1 -1
  50. package/dist/analyzer/packageTypeVerifier.js +8 -8
  51. package/dist/analyzer/packageTypeVerifier.js.map +1 -1
  52. package/dist/analyzer/parameterUtils.d.ts +10 -10
  53. package/dist/analyzer/parameterUtils.js +58 -58
  54. package/dist/analyzer/parameterUtils.js.map +1 -1
  55. package/dist/analyzer/parseTreeUtils.d.ts +6 -6
  56. package/dist/analyzer/parseTreeUtils.js +22 -22
  57. package/dist/analyzer/parseTreeUtils.js.map +1 -1
  58. package/dist/analyzer/patternMatching.js +108 -89
  59. package/dist/analyzer/patternMatching.js.map +1 -1
  60. package/dist/analyzer/program.js +11 -4
  61. package/dist/analyzer/program.js.map +1 -1
  62. package/dist/analyzer/properties.js +19 -19
  63. package/dist/analyzer/properties.js.map +1 -1
  64. package/dist/analyzer/protocols.js +14 -15
  65. package/dist/analyzer/protocols.js.map +1 -1
  66. package/dist/analyzer/pythonPathUtils.js +1 -1
  67. package/dist/analyzer/pythonPathUtils.js.map +1 -1
  68. package/dist/analyzer/service.d.ts +3 -7
  69. package/dist/analyzer/service.js +28 -30
  70. package/dist/analyzer/service.js.map +1 -1
  71. package/dist/analyzer/serviceUtils.d.ts +8 -0
  72. package/dist/analyzer/serviceUtils.js +31 -0
  73. package/dist/analyzer/serviceUtils.js.map +1 -0
  74. package/dist/analyzer/sourceFile.js +5 -19
  75. package/dist/analyzer/sourceFile.js.map +1 -1
  76. package/dist/analyzer/sourceMapper.d.ts +1 -1
  77. package/dist/analyzer/sourceMapper.js +4 -4
  78. package/dist/analyzer/sourceMapper.js.map +1 -1
  79. package/dist/analyzer/staticExpressions.js +1 -1
  80. package/dist/analyzer/staticExpressions.js.map +1 -1
  81. package/dist/analyzer/tracePrinter.js +4 -4
  82. package/dist/analyzer/tracePrinter.js.map +1 -1
  83. package/dist/analyzer/tuples.d.ts +9 -0
  84. package/dist/analyzer/tuples.js +252 -0
  85. package/dist/analyzer/tuples.js.map +1 -0
  86. package/dist/analyzer/typeComplexity.d.ts +2 -0
  87. package/dist/analyzer/typeComplexity.js +86 -0
  88. package/dist/analyzer/typeComplexity.js.map +1 -0
  89. package/dist/analyzer/typeEvaluator.js +1062 -1311
  90. package/dist/analyzer/typeEvaluator.js.map +1 -1
  91. package/dist/analyzer/typeEvaluatorTypes.d.ts +44 -40
  92. package/dist/analyzer/typeEvaluatorTypes.js +7 -1
  93. package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
  94. package/dist/analyzer/typeGuards.js +114 -85
  95. package/dist/analyzer/typeGuards.js.map +1 -1
  96. package/dist/analyzer/typePrinter.d.ts +1 -1
  97. package/dist/analyzer/typePrinter.js +54 -53
  98. package/dist/analyzer/typePrinter.js.map +1 -1
  99. package/dist/analyzer/typeStubWriter.d.ts +3 -3
  100. package/dist/analyzer/typeStubWriter.js +15 -15
  101. package/dist/analyzer/typeStubWriter.js.map +1 -1
  102. package/dist/analyzer/typeUtils.d.ts +20 -18
  103. package/dist/analyzer/typeUtils.js +316 -321
  104. package/dist/analyzer/typeUtils.js.map +1 -1
  105. package/dist/analyzer/typeVarContext.d.ts +24 -36
  106. package/dist/analyzer/typeVarContext.js +89 -193
  107. package/dist/analyzer/typeVarContext.js.map +1 -1
  108. package/dist/analyzer/typeWalker.js +4 -4
  109. package/dist/analyzer/typeWalker.js.map +1 -1
  110. package/dist/analyzer/typedDicts.d.ts +2 -2
  111. package/dist/analyzer/typedDicts.js +48 -52
  112. package/dist/analyzer/typedDicts.js.map +1 -1
  113. package/dist/analyzer/types.d.ts +79 -57
  114. package/dist/analyzer/types.js +125 -113
  115. package/dist/analyzer/types.js.map +1 -1
  116. package/dist/commands/dumpFileDebugInfoCommand.js +11 -11
  117. package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
  118. package/dist/common/configOptions.d.ts +1 -0
  119. package/dist/common/configOptions.js +5 -0
  120. package/dist/common/configOptions.js.map +1 -1
  121. package/dist/common/diagnosticRules.d.ts +1 -0
  122. package/dist/common/diagnosticRules.js +1 -0
  123. package/dist/common/diagnosticRules.js.map +1 -1
  124. package/dist/common/fileSystem.d.ts +0 -1
  125. package/dist/common/fileSystem.js.map +1 -1
  126. package/dist/common/languageServerInterface.d.ts +13 -0
  127. package/dist/common/languageServerInterface.js +15 -1
  128. package/dist/common/languageServerInterface.js.map +1 -1
  129. package/dist/common/lspUtils.js +2 -2
  130. package/dist/common/memUtils.d.ts +4 -0
  131. package/dist/common/memUtils.js +33 -2
  132. package/dist/common/memUtils.js.map +1 -1
  133. package/dist/common/serviceKeys.d.ts +3 -0
  134. package/dist/common/serviceKeys.js +2 -0
  135. package/dist/common/serviceKeys.js.map +1 -1
  136. package/dist/common/serviceProviderExtensions.js +7 -0
  137. package/dist/common/serviceProviderExtensions.js.map +1 -1
  138. package/dist/languageServerBase.d.ts +4 -3
  139. package/dist/languageServerBase.js +14 -10
  140. package/dist/languageServerBase.js.map +1 -1
  141. package/dist/languageService/autoImporter.d.ts +3 -2
  142. package/dist/languageService/autoImporter.js +5 -1
  143. package/dist/languageService/autoImporter.js.map +1 -1
  144. package/dist/languageService/completionProvider.d.ts +5 -3
  145. package/dist/languageService/completionProvider.js +38 -37
  146. package/dist/languageService/completionProvider.js.map +1 -1
  147. package/dist/languageService/completionProviderUtils.d.ts +1 -1
  148. package/dist/languageService/completionProviderUtils.js +3 -3
  149. package/dist/languageService/completionProviderUtils.js.map +1 -1
  150. package/dist/languageService/fileWatcherDynamicFeature.js +2 -2
  151. package/dist/languageService/fileWatcherDynamicFeature.js.map +1 -1
  152. package/dist/languageService/hoverProvider.js +3 -3
  153. package/dist/languageService/hoverProvider.js.map +1 -1
  154. package/dist/languageService/referencesProvider.js +2 -2
  155. package/dist/languageService/signatureHelpProvider.js +1 -1
  156. package/dist/languageService/signatureHelpProvider.js.map +1 -1
  157. package/dist/languageService/tooltipUtils.js +3 -3
  158. package/dist/languageService/tooltipUtils.js.map +1 -1
  159. package/dist/localization/localize.d.ts +5 -0
  160. package/dist/localization/localize.js +6 -0
  161. package/dist/localization/localize.js.map +1 -1
  162. package/dist/localization/package.nls.cs.json +5 -1
  163. package/dist/localization/package.nls.de.json +5 -1
  164. package/dist/localization/package.nls.en-us.json +5 -0
  165. package/dist/localization/package.nls.es.json +5 -1
  166. package/dist/localization/package.nls.fr.json +5 -1
  167. package/dist/localization/package.nls.it.json +5 -1
  168. package/dist/localization/package.nls.ja.json +5 -1
  169. package/dist/localization/package.nls.ko.json +5 -1
  170. package/dist/localization/package.nls.pl.json +5 -1
  171. package/dist/localization/package.nls.pt-br.json +5 -1
  172. package/dist/localization/package.nls.qps-ploc.json +5 -1
  173. package/dist/localization/package.nls.ru.json +5 -1
  174. package/dist/localization/package.nls.tr.json +5 -1
  175. package/dist/localization/package.nls.zh-cn.json +5 -1
  176. package/dist/localization/package.nls.zh-tw.json +5 -1
  177. package/dist/parser/parseNodes.d.ts +9 -9
  178. package/dist/parser/parseNodes.js +20 -20
  179. package/dist/parser/parseNodes.js.map +1 -1
  180. package/dist/parser/parser.js +30 -30
  181. package/dist/parser/parser.js.map +1 -1
  182. package/dist/tests/checker.test.js +2 -2
  183. package/dist/tests/fourslash/signature.builtinDocstrings.fourslash.js +4 -21
  184. package/dist/tests/fourslash/signature.builtinDocstrings.fourslash.js.map +1 -1
  185. package/dist/tests/fourslash/signature.complicated.fourslash.js +1 -1
  186. package/dist/tests/fourslash/signature.complicated.fourslash.js.map +1 -1
  187. package/dist/tests/harness/fourslash/fourSlashParser.js +1 -1
  188. package/dist/tests/harness/fourslash/fourSlashParser.js.map +1 -1
  189. package/dist/tests/harness/fourslash/testStateUtils.js +2 -2
  190. package/dist/tests/harness/fourslash/testStateUtils.js.map +1 -1
  191. package/dist/tests/harness/vfs/filesystem.d.ts +0 -1
  192. package/dist/tests/harness/vfs/filesystem.js +0 -4
  193. package/dist/tests/harness/vfs/filesystem.js.map +1 -1
  194. package/dist/tests/importResolver.test.js +62 -15
  195. package/dist/tests/importResolver.test.js.map +1 -1
  196. package/dist/tests/lsp/languageServerTestUtils.js +1 -1
  197. package/dist/tests/lsp/languageServerTestUtils.js.map +1 -1
  198. package/dist/tests/typeEvaluator3.test.js +1 -1
  199. package/dist/tests/typeEvaluator4.test.js +9 -1
  200. package/dist/tests/typeEvaluator4.test.js.map +1 -1
  201. package/dist/tests/typeEvaluator5.test.js +8 -2
  202. package/dist/tests/typeEvaluator5.test.js.map +1 -1
  203. package/dist/tests/typeEvaluator6.test.js +72 -60
  204. package/dist/tests/typeEvaluator6.test.js.map +1 -1
  205. package/dist/tests/typeEvaluator7.test.js +2 -2
  206. package/dist/tests/typePrinter.test.js +13 -18
  207. package/dist/tests/typePrinter.test.js.map +1 -1
  208. package/dist/workspaceFactory.d.ts +3 -2
  209. package/dist/workspaceFactory.js +15 -2
  210. package/dist/workspaceFactory.js.map +1 -1
  211. 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.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.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.updateTypeWithExternalTypeVars = exports.updateTypeWithInternalTypeVars = 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 = exports.combineVariances = exports.requiresSpecialization = void 0;
11
+ exports.isTupleClass = 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.getUnknownForTypeVarTuple = exports.getUnknownForTypeVar = 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.requiresTypeArgs = exports.getGeneratorTypeArgs = exports.specializeTupleClass = exports.combineTupleTypeArgs = 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.setTypeArgsRecursive = exports.specializeClassType = exports.getTypeVarArgsRecursive = 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.updateTypeWithExternalTypeVars = exports.updateTypeWithInternalTypeVars = exports.ensureFunctionSignaturesAreUnique = exports.populateTypeVarContextForSelfType = exports.partiallySpecializeType = exports.isTupleIndexUnambiguous = exports.isUnboundedTupleClass = void 0;
13
+ exports.convertParamSpecValueToType = exports.setTypeVarType = exports.convertTypeToParamSpecValue = exports.convertNodeToArg = exports.getDeclaringModulesForType = exports.computeMroLinearization = exports.isVarianceOfTypeArgCompatible = exports.combineVariances = exports.requiresSpecialization = 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");
@@ -103,8 +103,6 @@ var AssignTypeFlags;
103
103
  AssignTypeFlags[AssignTypeFlags["PartialOverloadOverlap"] = 32] = "PartialOverloadOverlap";
104
104
  // For function types, skip the return type check.
105
105
  AssignTypeFlags[AssignTypeFlags["SkipReturnTypeCheck"] = 64] = "SkipReturnTypeCheck";
106
- // Allow bool values to be assigned to TypeGuard[x] types.
107
- AssignTypeFlags[AssignTypeFlags["AllowBoolTypeGuard"] = 128] = "AllowBoolTypeGuard";
108
106
  // In most cases, literals are stripped when assigning to a
109
107
  // type variable. This overrides the standard behavior.
110
108
  AssignTypeFlags[AssignTypeFlags["RetainLiteralsForTypeVar"] = 256] = "RetainLiteralsForTypeVar";
@@ -128,7 +126,7 @@ var AssignTypeFlags;
128
126
  // hasn't previously been specialized, it will be specialized with
129
127
  // default type arguments (typically "Unknown"). This flag skips
130
128
  // this step.
131
- AssignTypeFlags[AssignTypeFlags["AllowUnspecifiedTypeArguments"] = 8192] = "AllowUnspecifiedTypeArguments";
129
+ AssignTypeFlags[AssignTypeFlags["AllowUnspecifiedTypeArgs"] = 8192] = "AllowUnspecifiedTypeArgs";
132
130
  // Normally all special form classes are incompatible with type[T],
133
131
  // but a few of them are allowed in the context of an isinstance
134
132
  // or issubclass call.
@@ -216,7 +214,7 @@ function isTypeVarSame(type1, type2) {
216
214
  return true;
217
215
  }
218
216
  // If this isn't a bound TypeVar, return false.
219
- if (type1.shared.isParamSpec || type1.shared.isVariadic || !type1.shared.boundType) {
217
+ if ((0, types_1.isParamSpec)(type1) || (0, types_1.isTypeVarTuple)(type1) || !type1.shared.boundType) {
220
218
  return false;
221
219
  }
222
220
  // If the second type isn't a union, return false.
@@ -349,10 +347,10 @@ function cleanIncompleteUnknown(type, recursionCount = 0) {
349
347
  if ((0, types_1.isUnknown)(subtype) && subtype.priv.isIncomplete) {
350
348
  return undefined;
351
349
  }
352
- if ((0, types_1.isClass)(subtype) && subtype.priv.typeArguments) {
350
+ if ((0, types_1.isClass)(subtype) && subtype.priv.typeArgs) {
353
351
  let typeChanged = false;
354
- if (subtype.priv.tupleTypeArguments) {
355
- const updatedTupleTypeArgs = subtype.priv.tupleTypeArguments.map((tupleTypeArg) => {
352
+ if (subtype.priv.tupleTypeArgs) {
353
+ const updatedTupleTypeArgs = subtype.priv.tupleTypeArgs.map((tupleTypeArg) => {
356
354
  const newTypeArg = cleanIncompleteUnknown(tupleTypeArg.type, recursionCount);
357
355
  if (newTypeArg !== tupleTypeArg.type) {
358
356
  typeChanged = true;
@@ -364,11 +362,11 @@ function cleanIncompleteUnknown(type, recursionCount = 0) {
364
362
  };
365
363
  });
366
364
  if (typeChanged) {
367
- return specializeTupleClass(subtype, updatedTupleTypeArgs, !!subtype.priv.isTypeArgumentExplicit, !!subtype.priv.isUnpacked);
365
+ return specializeTupleClass(subtype, updatedTupleTypeArgs, !!subtype.priv.isTypeArgExplicit, !!subtype.priv.isUnpacked);
368
366
  }
369
367
  }
370
368
  else {
371
- const updatedTypeArgs = subtype.priv.typeArguments.map((typeArg) => {
369
+ const updatedTypeArgs = subtype.priv.typeArgs.map((typeArg) => {
372
370
  const newTypeArg = cleanIncompleteUnknown(typeArg, recursionCount);
373
371
  if (newTypeArg !== typeArg) {
374
372
  typeChanged = true;
@@ -376,7 +374,7 @@ function cleanIncompleteUnknown(type, recursionCount = 0) {
376
374
  return newTypeArg;
377
375
  });
378
376
  if (typeChanged) {
379
- return types_1.ClassType.cloneForSpecialization(subtype, updatedTypeArgs, !!subtype.priv.isTypeArgumentExplicit);
377
+ return types_1.ClassType.specialize(subtype, updatedTypeArgs, !!subtype.priv.isTypeArgExplicit);
380
378
  }
381
379
  }
382
380
  }
@@ -424,7 +422,7 @@ function compareTypes(a, b, recursionCount = 0) {
424
422
  if (aParam.category !== bParam.category) {
425
423
  return bParam.category - aParam.category;
426
424
  }
427
- const typeComparison = compareTypes(types_1.FunctionType.getEffectiveParameterType(a, i), types_1.FunctionType.getEffectiveParameterType(bFunc, i));
425
+ const typeComparison = compareTypes(types_1.FunctionType.getEffectiveParamType(a, i), types_1.FunctionType.getEffectiveParamType(bFunc, i));
428
426
  if (typeComparison !== 0) {
429
427
  return typeComparison;
430
428
  }
@@ -484,12 +482,12 @@ function compareTypes(a, b, recursionCount = 0) {
484
482
  return -1;
485
483
  }
486
484
  // Sort non-generics before generics.
487
- if (a.shared.typeParameters.length > 0 || isTupleClass(a)) {
488
- if (bClass.shared.typeParameters.length === 0) {
485
+ if (a.shared.typeParams.length > 0 || isTupleClass(a)) {
486
+ if (bClass.shared.typeParams.length === 0) {
489
487
  return 1;
490
488
  }
491
489
  }
492
- else if (bClass.shared.typeParameters.length > 0 || isTupleClass(bClass)) {
490
+ else if (bClass.shared.typeParams.length > 0 || isTupleClass(bClass)) {
493
491
  return -1;
494
492
  }
495
493
  // Sort by class name.
@@ -502,8 +500,8 @@ function compareTypes(a, b, recursionCount = 0) {
502
500
  return 1;
503
501
  }
504
502
  // Sort by type argument count.
505
- const aTypeArgCount = a.priv.typeArguments ? a.priv.typeArguments.length : 0;
506
- const bTypeArgCount = bClass.priv.typeArguments ? bClass.priv.typeArguments.length : 0;
503
+ const aTypeArgCount = a.priv.typeArgs ? a.priv.typeArgs.length : 0;
504
+ const bTypeArgCount = bClass.priv.typeArgs ? bClass.priv.typeArgs.length : 0;
507
505
  if (aTypeArgCount < bTypeArgCount) {
508
506
  return -1;
509
507
  }
@@ -512,7 +510,7 @@ function compareTypes(a, b, recursionCount = 0) {
512
510
  }
513
511
  // Sort by type argument.
514
512
  for (let i = 0; i < aTypeArgCount; i++) {
515
- const typeComparison = compareTypes(a.priv.typeArguments[i], bClass.priv.typeArguments[i], recursionCount);
513
+ const typeComparison = compareTypes(a.priv.typeArgs[i], bClass.priv.typeArgs[i], recursionCount);
516
514
  if (typeComparison !== 0) {
517
515
  return typeComparison;
518
516
  }
@@ -744,17 +742,17 @@ function transformPossibleRecursiveTypeAlias(type) {
744
742
  const unspecializedType = types_1.TypeBase.isInstance(type)
745
743
  ? convertToInstance(type.shared.boundType)
746
744
  : type.shared.boundType;
747
- if (!(aliasInfo === null || aliasInfo === void 0 ? void 0 : aliasInfo.typeArguments) || !type.shared.recursiveAlias.typeParameters) {
745
+ if (!(aliasInfo === null || aliasInfo === void 0 ? void 0 : aliasInfo.typeArgs) || !type.shared.recursiveAlias.typeParams) {
748
746
  return unspecializedType;
749
747
  }
750
- const typeVarContext = buildTypeVarContext(type.shared.recursiveAlias.typeParameters, aliasInfo.typeArguments, getTypeVarScopeId(type));
748
+ const typeVarContext = buildTypeVarContext(type.shared.recursiveAlias.typeParams, aliasInfo.typeArgs, getTypeVarScopeId(type));
751
749
  return applySolvedTypeVars(unspecializedType, typeVarContext);
752
750
  }
753
751
  if ((0, types_1.isUnion)(type) && type.priv.includesRecursiveTypeAlias) {
754
752
  let newType = mapSubtypes(type, (subtype) => transformPossibleRecursiveTypeAlias(subtype));
755
753
  if (newType !== type && aliasInfo) {
756
754
  // Copy the type alias information if present.
757
- newType = types_1.TypeBase.cloneForTypeAlias(newType, aliasInfo.name, aliasInfo.fullName, aliasInfo.moduleName, aliasInfo.fileUri, aliasInfo.typeVarScopeId, aliasInfo.isPep695Syntax, aliasInfo.typeParameters, aliasInfo.typeArguments);
755
+ newType = types_1.TypeBase.cloneForTypeAlias(newType, aliasInfo.name, aliasInfo.fullName, aliasInfo.moduleName, aliasInfo.fileUri, aliasInfo.typeVarScopeId, aliasInfo.isPep695Syntax, aliasInfo.typeParams, aliasInfo.typeArgs);
758
756
  }
759
757
  return newType;
760
758
  }
@@ -798,58 +796,51 @@ exports.getTypeVarScopeIds = getTypeVarScopeIds;
798
796
  // specified, specialize it with default type arguments (Unknown or the
799
797
  // default type if provided).
800
798
  function specializeWithDefaultTypeArgs(type) {
801
- if (type.shared.typeParameters.length === 0 || type.priv.typeArguments) {
799
+ if (type.shared.typeParams.length === 0 || type.priv.typeArgs) {
802
800
  return type;
803
801
  }
804
- return types_1.ClassType.cloneForSpecialization(type, type.shared.typeParameters.map((param) => param.shared.defaultType),
805
- /* isTypeArgumentExplicit */ false,
802
+ return types_1.ClassType.specialize(type, type.shared.typeParams.map((param) => param.shared.defaultType),
803
+ /* isTypeArgExplicit */ false,
806
804
  /* includeSubclasses */ type.priv.includeSubclasses);
807
805
  }
808
806
  exports.specializeWithDefaultTypeArgs = specializeWithDefaultTypeArgs;
809
807
  // Specializes the class with "Unknown" type args (or the equivalent for ParamSpecs
810
808
  // or TypeVarTuples).
811
809
  function specializeWithUnknownTypeArgs(type, tupleClassType) {
812
- if (type.shared.typeParameters.length === 0) {
810
+ if (type.shared.typeParams.length === 0) {
813
811
  return type;
814
812
  }
815
813
  if (isTupleClass(type)) {
816
814
  return types_1.ClassType.cloneIncludeSubclasses(specializeTupleClass(type, [{ type: types_1.UnknownType.create(), isUnbounded: true }],
817
- /* isTypeArgumentExplicit */ false), !!type.priv.includeSubclasses);
815
+ /* isTypeArgExplicit */ false), !!type.priv.includeSubclasses);
818
816
  }
819
- return types_1.ClassType.cloneForSpecialization(type, type.shared.typeParameters.map((param) => getUnknownTypeForTypeVar(param, tupleClassType)),
820
- /* isTypeArgumentExplicit */ false,
817
+ return types_1.ClassType.specialize(type, type.shared.typeParams.map((param) => getUnknownForTypeVar(param, tupleClassType)),
818
+ /* isTypeArgExplicit */ false,
821
819
  /* includeSubclasses */ type.priv.includeSubclasses);
822
820
  }
823
821
  exports.specializeWithUnknownTypeArgs = specializeWithUnknownTypeArgs;
824
822
  // Returns "Unknown" for simple TypeVars or the equivalent for a ParamSpec.
825
- function getUnknownTypeForTypeVar(typeVar, tupleClassType) {
826
- if (typeVar.shared.isParamSpec) {
827
- return getUnknownTypeForParamSpec();
823
+ function getUnknownForTypeVar(typeVar, tupleClassType) {
824
+ if ((0, types_1.isParamSpec)(typeVar)) {
825
+ return types_1.ParamSpecType.getUnknown();
828
826
  }
829
- if (typeVar.shared.isVariadic && tupleClassType) {
830
- return getUnknownTypeForVariadicTypeVar(tupleClassType);
827
+ if ((0, types_1.isTypeVarTuple)(typeVar) && tupleClassType) {
828
+ return getUnknownForTypeVarTuple(tupleClassType);
831
829
  }
832
830
  return types_1.UnknownType.create();
833
831
  }
834
- exports.getUnknownTypeForTypeVar = getUnknownTypeForTypeVar;
835
- // Returns the "Unknown" equivalent for a ParamSpec.
836
- function getUnknownTypeForParamSpec() {
837
- const newFunction = types_1.FunctionType.createInstance('', '', '', 65536 /* FunctionTypeFlags.ParamSpecValue */ | 32768 /* FunctionTypeFlags.GradualCallableForm */);
838
- types_1.FunctionType.addDefaultParameters(newFunction);
839
- return newFunction;
840
- }
841
- exports.getUnknownTypeForParamSpec = getUnknownTypeForParamSpec;
842
- function getUnknownTypeForVariadicTypeVar(tupleClassType) {
832
+ exports.getUnknownForTypeVar = getUnknownForTypeVar;
833
+ function getUnknownForTypeVarTuple(tupleClassType) {
843
834
  (0, debug_1.assert)((0, types_1.isInstantiableClass)(tupleClassType) && types_1.ClassType.isBuiltIn(tupleClassType, 'tuple'));
844
835
  return types_1.ClassType.cloneAsInstance(specializeTupleClass(tupleClassType, [{ type: types_1.UnknownType.create(), isUnbounded: true }],
845
- /* isTypeArgumentExplicit */ true,
836
+ /* isTypeArgExplicit */ true,
846
837
  /* isUnpackedTuple */ true));
847
838
  }
848
- exports.getUnknownTypeForVariadicTypeVar = getUnknownTypeForVariadicTypeVar;
839
+ exports.getUnknownForTypeVarTuple = getUnknownForTypeVarTuple;
849
840
  // Returns the equivalent of "Callable[..., Unknown]".
850
841
  function getUnknownTypeForCallable() {
851
842
  const newFunction = types_1.FunctionType.createSynthesizedInstance('', 32768 /* FunctionTypeFlags.GradualCallableForm */);
852
- types_1.FunctionType.addDefaultParameters(newFunction);
843
+ types_1.FunctionType.addDefaultParams(newFunction);
853
844
  newFunction.shared.declaredReturnType = types_1.UnknownType.create();
854
845
  return newFunction;
855
846
  }
@@ -858,16 +849,16 @@ exports.getUnknownTypeForCallable = getUnknownTypeForCallable;
858
849
  // "self specializes" the class, filling in its own type parameters
859
850
  // as type arguments.
860
851
  function selfSpecializeClass(type, options) {
861
- if (type.shared.typeParameters.length === 0) {
852
+ if (type.shared.typeParams.length === 0) {
862
853
  return type;
863
854
  }
864
- if (type.priv.typeArguments && !(options === null || options === void 0 ? void 0 : options.overrideTypeArgs)) {
855
+ if (type.priv.typeArgs && !(options === null || options === void 0 ? void 0 : options.overrideTypeArgs)) {
865
856
  return type;
866
857
  }
867
- const typeParams = type.shared.typeParameters.map((typeParam) => {
858
+ const typeParams = type.shared.typeParams.map((typeParam) => {
868
859
  return (options === null || options === void 0 ? void 0 : options.useInternalTypeVars) ? types_1.TypeVarType.cloneWithInternalScopeId(typeParam) : typeParam;
869
860
  });
870
- return types_1.ClassType.cloneForSpecialization(type, typeParams, /* isTypeArgumentExplicit */ true);
861
+ return types_1.ClassType.specialize(type, typeParams);
871
862
  }
872
863
  exports.selfSpecializeClass = selfSpecializeClass;
873
864
  // Determines whether the type derives from tuple. If so, it returns
@@ -1034,10 +1025,10 @@ exports.isMaybeDescriptorInstance = isMaybeDescriptorInstance;
1034
1025
  function isTupleGradualForm(type) {
1035
1026
  return ((0, types_1.isClassInstance)(type) &&
1036
1027
  isTupleClass(type) &&
1037
- type.priv.tupleTypeArguments &&
1038
- type.priv.tupleTypeArguments.length === 1 &&
1039
- (0, types_1.isAnyOrUnknown)(type.priv.tupleTypeArguments[0].type) &&
1040
- type.priv.tupleTypeArguments[0].isUnbounded);
1028
+ type.priv.tupleTypeArgs &&
1029
+ type.priv.tupleTypeArgs.length === 1 &&
1030
+ (0, types_1.isAnyOrUnknown)(type.priv.tupleTypeArgs[0].type) &&
1031
+ type.priv.tupleTypeArgs[0].isUnbounded);
1041
1032
  }
1042
1033
  exports.isTupleGradualForm = isTupleGradualForm;
1043
1034
  function isTupleClass(type) {
@@ -1048,23 +1039,23 @@ exports.isTupleClass = isTupleClass;
1048
1039
  // the form tuple[x, ...] where the number of elements
1049
1040
  // in the tuple is unknown.
1050
1041
  function isUnboundedTupleClass(type) {
1051
- return (type.priv.tupleTypeArguments &&
1052
- type.priv.tupleTypeArguments.some((t) => t.isUnbounded || (0, types_1.isUnpackedVariadicTypeVar)(t.type)));
1042
+ var _a;
1043
+ return (_a = type.priv.tupleTypeArgs) === null || _a === void 0 ? void 0 : _a.some((t) => t.isUnbounded || (0, types_1.isUnpackedTypeVarTuple)(t.type));
1053
1044
  }
1054
1045
  exports.isUnboundedTupleClass = isUnboundedTupleClass;
1055
1046
  // Indicates whether the specified index is within range and its type is unambiguous
1056
1047
  // in that it doesn't involve any element ranges that are of indeterminate length.
1057
1048
  function isTupleIndexUnambiguous(type, index) {
1058
- if (!type.priv.tupleTypeArguments) {
1049
+ if (!type.priv.tupleTypeArgs) {
1059
1050
  return false;
1060
1051
  }
1061
- const unboundedIndex = type.priv.tupleTypeArguments.findIndex((t) => t.isUnbounded || (0, types_1.isUnpackedVariadicTypeVar)(t.type));
1052
+ const unboundedIndex = type.priv.tupleTypeArgs.findIndex((t) => t.isUnbounded || (0, types_1.isUnpackedTypeVarTuple)(t.type));
1062
1053
  if (index < 0) {
1063
1054
  const lowerIndexLimit = unboundedIndex < 0 ? 0 : unboundedIndex;
1064
- index += type.priv.tupleTypeArguments.length;
1055
+ index += type.priv.tupleTypeArgs.length;
1065
1056
  return index >= lowerIndexLimit;
1066
1057
  }
1067
- const upperIndexLimit = unboundedIndex < 0 ? type.priv.tupleTypeArguments.length : unboundedIndex;
1058
+ const upperIndexLimit = unboundedIndex < 0 ? type.priv.tupleTypeArgs.length : unboundedIndex;
1068
1059
  return index < upperIndexLimit;
1069
1060
  }
1070
1061
  exports.isTupleIndexUnambiguous = isTupleIndexUnambiguous;
@@ -1119,7 +1110,7 @@ function populateTypeVarContextForSelfType(typeVarContext, contextClassType, sel
1119
1110
  return subtype;
1120
1111
  });
1121
1112
  if (!(0, types_1.isTypeSame)(synthesizedSelfTypeVar, selfWithoutLiteral)) {
1122
- typeVarContext.setTypeVarType(synthesizedSelfTypeVar, selfInstance, selfWithoutLiteral);
1113
+ setTypeVarType(typeVarContext, synthesizedSelfTypeVar, selfInstance, selfWithoutLiteral);
1123
1114
  }
1124
1115
  }
1125
1116
  exports.populateTypeVarContextForSelfType = populateTypeVarContextForSelfType;
@@ -1162,28 +1153,19 @@ function applySourceContextTypeVars(destContext, srcContext) {
1162
1153
  if (srcContext.isEmpty()) {
1163
1154
  return;
1164
1155
  }
1165
- destContext.doForEachSignatureContext((destSignature) => {
1166
- applySourceContextTypeVarsToSignature(destSignature, srcContext);
1156
+ destContext.doForEachSolutionSet((solutionSet) => {
1157
+ applySourceContextTypeVarsToSignature(solutionSet, srcContext);
1167
1158
  });
1168
1159
  }
1169
1160
  exports.applySourceContextTypeVars = applySourceContextTypeVars;
1170
- function applySourceContextTypeVarsToSignature(destSignature, srcContext) {
1171
- destSignature.getTypeVars().forEach((entry) => {
1172
- const newNarrowTypeBound = entry.narrowBound ? applySolvedTypeVars(entry.narrowBound, srcContext) : undefined;
1173
- const newNarrowTypeBoundNoLiterals = entry.narrowBoundNoLiterals
1174
- ? applySolvedTypeVars(entry.narrowBoundNoLiterals, srcContext)
1161
+ function applySourceContextTypeVarsToSignature(solutionSet, srcContext) {
1162
+ solutionSet.getTypeVars().forEach((entry) => {
1163
+ const newLowerBound = entry.lowerBound ? applySolvedTypeVars(entry.lowerBound, srcContext) : undefined;
1164
+ const newLowerBoundNoLiterals = entry.lowerBoundNoLiterals
1165
+ ? applySolvedTypeVars(entry.lowerBoundNoLiterals, srcContext)
1175
1166
  : undefined;
1176
- const newWideTypeBound = entry.wideBound ? applySolvedTypeVars(entry.wideBound, srcContext) : undefined;
1177
- destSignature.setTypeVarType(entry.typeVar, newNarrowTypeBound, newNarrowTypeBoundNoLiterals, newWideTypeBound);
1178
- if (entry.tupleTypes) {
1179
- destSignature.setTupleTypeVar(entry.typeVar, entry.tupleTypes.map((arg) => {
1180
- return {
1181
- type: applySolvedTypeVars(arg.type, srcContext),
1182
- isUnbounded: arg.isUnbounded,
1183
- isOptional: arg.isOptional,
1184
- };
1185
- }));
1186
- }
1167
+ const newUpperBound = entry.upperBound ? applySolvedTypeVars(entry.upperBound, srcContext) : undefined;
1168
+ solutionSet.setTypeVarType(entry.typeVar, newLowerBound, newLowerBoundNoLiterals, newUpperBound);
1187
1169
  });
1188
1170
  }
1189
1171
  exports.applySourceContextTypeVarsToSignature = applySourceContextTypeVarsToSignature;
@@ -1191,29 +1173,20 @@ exports.applySourceContextTypeVarsToSignature = applySourceContextTypeVarsToSign
1191
1173
  // in-scope placeholders used for bidirectional type inference, replace those
1192
1174
  // with the solved type associated with those in-scope placeholders.
1193
1175
  function applyInScopePlaceholders(typeVarContext) {
1194
- typeVarContext.doForEachSignatureContext((signature) => {
1195
- signature.getTypeVars().forEach((entry) => {
1176
+ typeVarContext.doForEachSolutionSet((solutionSet) => {
1177
+ solutionSet.getTypeVars().forEach((entry) => {
1196
1178
  const typeVar = entry.typeVar;
1197
1179
  if (!typeVar.priv.isInScopePlaceholder) {
1198
- const newNarrowTypeBound = entry.narrowBound
1199
- ? applyInScopePlaceholdersToType(entry.narrowBound, signature)
1180
+ const newLowerBound = entry.lowerBound
1181
+ ? applyInScopePlaceholdersToType(entry.lowerBound, solutionSet)
1200
1182
  : undefined;
1201
- const newNarrowTypeBoundNoLiterals = entry.narrowBoundNoLiterals
1202
- ? applyInScopePlaceholdersToType(entry.narrowBoundNoLiterals, signature)
1183
+ const newLowerBoundNoLiterals = entry.lowerBoundNoLiterals
1184
+ ? applyInScopePlaceholdersToType(entry.lowerBoundNoLiterals, solutionSet)
1203
1185
  : undefined;
1204
- const newWideTypeBound = entry.wideBound
1205
- ? applyInScopePlaceholdersToType(entry.wideBound, signature)
1186
+ const newUpperBound = entry.upperBound
1187
+ ? applyInScopePlaceholdersToType(entry.upperBound, solutionSet)
1206
1188
  : undefined;
1207
- signature.setTypeVarType(entry.typeVar, newNarrowTypeBound, newNarrowTypeBoundNoLiterals, newWideTypeBound);
1208
- if (entry.tupleTypes) {
1209
- signature.setTupleTypeVar(entry.typeVar, entry.tupleTypes.map((arg) => {
1210
- return {
1211
- type: applyInScopePlaceholdersToType(arg.type, signature),
1212
- isUnbounded: arg.isUnbounded,
1213
- isOptional: arg.isOptional,
1214
- };
1215
- }));
1216
- }
1189
+ solutionSet.setTypeVarType(entry.typeVar, newLowerBound, newLowerBoundNoLiterals, newUpperBound);
1217
1190
  }
1218
1191
  });
1219
1192
  });
@@ -1293,16 +1266,16 @@ function getContainerDepth(type, recursionCount = 0) {
1293
1266
  return 0;
1294
1267
  }
1295
1268
  let maxChildDepth = 0;
1296
- if (type.priv.tupleTypeArguments) {
1297
- type.priv.tupleTypeArguments.forEach((typeArgInfo) => {
1269
+ if (type.priv.tupleTypeArgs) {
1270
+ type.priv.tupleTypeArgs.forEach((typeArgInfo) => {
1298
1271
  doForEachSubtype(typeArgInfo.type, (subtype) => {
1299
1272
  const childDepth = getContainerDepth(subtype, recursionCount);
1300
1273
  maxChildDepth = Math.max(childDepth, maxChildDepth);
1301
1274
  });
1302
1275
  });
1303
1276
  }
1304
- else if (type.priv.typeArguments) {
1305
- type.priv.typeArguments.forEach((typeArg) => {
1277
+ else if (type.priv.typeArgs) {
1278
+ type.priv.typeArgs.forEach((typeArg) => {
1306
1279
  doForEachSubtype(typeArg, (subtype) => {
1307
1280
  const childDepth = getContainerDepth(subtype, recursionCount);
1308
1281
  maxChildDepth = Math.max(childDepth, maxChildDepth);
@@ -1575,17 +1548,17 @@ exports.addTypeVarsToListIfUnique = addTypeVarsToListIfUnique;
1575
1548
  // of unique type variables. For example, if the type is
1576
1549
  // Union[List[Dict[_T1, _T2]], _T1, _T3], the result would be
1577
1550
  // [_T1, _T2, _T3].
1578
- function getTypeVarArgumentsRecursive(type, recursionCount = 0) {
1551
+ function getTypeVarArgsRecursive(type, recursionCount = 0) {
1579
1552
  var _a;
1580
1553
  if (recursionCount > types_1.maxTypeRecursionCount) {
1581
1554
  return [];
1582
1555
  }
1583
1556
  recursionCount++;
1584
1557
  const aliasInfo = (_a = type.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo;
1585
- if (aliasInfo === null || aliasInfo === void 0 ? void 0 : aliasInfo.typeArguments) {
1558
+ if (aliasInfo === null || aliasInfo === void 0 ? void 0 : aliasInfo.typeArgs) {
1586
1559
  const combinedList = [];
1587
- aliasInfo === null || aliasInfo === void 0 ? void 0 : aliasInfo.typeArguments.forEach((typeArg) => {
1588
- addTypeVarsToListIfUnique(combinedList, getTypeVarArgumentsRecursive(typeArg, recursionCount));
1560
+ aliasInfo === null || aliasInfo === void 0 ? void 0 : aliasInfo.typeArgs.forEach((typeArg) => {
1561
+ addTypeVarsToListIfUnique(combinedList, getTypeVarArgsRecursive(typeArg, recursionCount));
1589
1562
  });
1590
1563
  return combinedList;
1591
1564
  }
@@ -1602,12 +1575,10 @@ function getTypeVarArgumentsRecursive(type, recursionCount = 0) {
1602
1575
  }
1603
1576
  if ((0, types_1.isClass)(type)) {
1604
1577
  const combinedList = [];
1605
- const typeArgs = type.priv.tupleTypeArguments
1606
- ? type.priv.tupleTypeArguments.map((e) => e.type)
1607
- : type.priv.typeArguments;
1578
+ const typeArgs = type.priv.tupleTypeArgs ? type.priv.tupleTypeArgs.map((e) => e.type) : type.priv.typeArgs;
1608
1579
  if (typeArgs) {
1609
1580
  typeArgs.forEach((typeArg) => {
1610
- addTypeVarsToListIfUnique(combinedList, getTypeVarArgumentsRecursive(typeArg, recursionCount));
1581
+ addTypeVarsToListIfUnique(combinedList, getTypeVarArgsRecursive(typeArg, recursionCount));
1611
1582
  });
1612
1583
  }
1613
1584
  return combinedList;
@@ -1615,38 +1586,38 @@ function getTypeVarArgumentsRecursive(type, recursionCount = 0) {
1615
1586
  if ((0, types_1.isUnion)(type)) {
1616
1587
  const combinedList = [];
1617
1588
  doForEachSubtype(type, (subtype) => {
1618
- addTypeVarsToListIfUnique(combinedList, getTypeVarArgumentsRecursive(subtype, recursionCount));
1589
+ addTypeVarsToListIfUnique(combinedList, getTypeVarArgsRecursive(subtype, recursionCount));
1619
1590
  });
1620
1591
  return combinedList;
1621
1592
  }
1622
1593
  if ((0, types_1.isFunction)(type)) {
1623
1594
  const combinedList = [];
1624
1595
  for (let i = 0; i < type.shared.parameters.length; i++) {
1625
- addTypeVarsToListIfUnique(combinedList, getTypeVarArgumentsRecursive(types_1.FunctionType.getEffectiveParameterType(type, i), recursionCount));
1596
+ addTypeVarsToListIfUnique(combinedList, getTypeVarArgsRecursive(types_1.FunctionType.getEffectiveParamType(type, i), recursionCount));
1626
1597
  }
1627
1598
  const returnType = types_1.FunctionType.getEffectiveReturnType(type);
1628
1599
  if (returnType) {
1629
- addTypeVarsToListIfUnique(combinedList, getTypeVarArgumentsRecursive(returnType, recursionCount));
1600
+ addTypeVarsToListIfUnique(combinedList, getTypeVarArgsRecursive(returnType, recursionCount));
1630
1601
  }
1631
1602
  return combinedList;
1632
1603
  }
1633
1604
  return [];
1634
1605
  }
1635
- exports.getTypeVarArgumentsRecursive = getTypeVarArgumentsRecursive;
1606
+ exports.getTypeVarArgsRecursive = getTypeVarArgsRecursive;
1636
1607
  // Creates a specialized version of the class, filling in any unspecified
1637
1608
  // type arguments with Unknown.
1638
1609
  function specializeClassType(type) {
1639
1610
  const typeVarContext = new typeVarContext_1.TypeVarContext(getTypeVarScopeId(type));
1640
- const typeParams = types_1.ClassType.getTypeParameters(type);
1611
+ const typeParams = types_1.ClassType.getTypeParams(type);
1641
1612
  typeParams.forEach((typeParam) => {
1642
- typeVarContext.setTypeVarType(typeParam, applySolvedTypeVars(typeParam.shared.defaultType, typeVarContext));
1613
+ setTypeVarType(typeVarContext, typeParam, applySolvedTypeVars(typeParam.shared.defaultType, typeVarContext));
1643
1614
  });
1644
1615
  return applySolvedTypeVars(type, typeVarContext);
1645
1616
  }
1646
1617
  exports.specializeClassType = specializeClassType;
1647
1618
  // Recursively finds all of the type arguments and sets them
1648
1619
  // to the specified srcType.
1649
- function setTypeArgumentsRecursive(destType, srcType, typeVarContext, recursionCount = 0) {
1620
+ function setTypeArgsRecursive(destType, srcType, typeVarContext, recursionCount = 0) {
1650
1621
  if (recursionCount > types_1.maxTypeRecursionCount) {
1651
1622
  return;
1652
1623
  }
@@ -1657,83 +1628,89 @@ function setTypeArgumentsRecursive(destType, srcType, typeVarContext, recursionC
1657
1628
  switch (destType.category) {
1658
1629
  case 8 /* TypeCategory.Union */:
1659
1630
  doForEachSubtype(destType, (subtype) => {
1660
- setTypeArgumentsRecursive(subtype, srcType, typeVarContext, recursionCount);
1631
+ setTypeArgsRecursive(subtype, srcType, typeVarContext, recursionCount);
1661
1632
  });
1662
1633
  break;
1663
1634
  case 6 /* TypeCategory.Class */:
1664
- if (destType.priv.typeArguments) {
1665
- destType.priv.typeArguments.forEach((typeArg) => {
1666
- setTypeArgumentsRecursive(typeArg, srcType, typeVarContext, recursionCount);
1635
+ if (destType.priv.typeArgs) {
1636
+ destType.priv.typeArgs.forEach((typeArg) => {
1637
+ setTypeArgsRecursive(typeArg, srcType, typeVarContext, recursionCount);
1667
1638
  });
1668
1639
  }
1669
- if (destType.priv.tupleTypeArguments) {
1670
- destType.priv.tupleTypeArguments.forEach((typeArg) => {
1671
- setTypeArgumentsRecursive(typeArg.type, srcType, typeVarContext, recursionCount);
1640
+ if (destType.priv.tupleTypeArgs) {
1641
+ destType.priv.tupleTypeArgs.forEach((typeArg) => {
1642
+ setTypeArgsRecursive(typeArg.type, srcType, typeVarContext, recursionCount);
1672
1643
  });
1673
1644
  }
1674
1645
  break;
1675
1646
  case 4 /* TypeCategory.Function */:
1676
1647
  if (destType.priv.specializedTypes) {
1677
1648
  destType.priv.specializedTypes.parameterTypes.forEach((paramType) => {
1678
- setTypeArgumentsRecursive(paramType, srcType, typeVarContext, recursionCount);
1649
+ setTypeArgsRecursive(paramType, srcType, typeVarContext, recursionCount);
1679
1650
  });
1680
1651
  if (destType.priv.specializedTypes.returnType) {
1681
- setTypeArgumentsRecursive(destType.priv.specializedTypes.returnType, srcType, typeVarContext, recursionCount);
1652
+ setTypeArgsRecursive(destType.priv.specializedTypes.returnType, srcType, typeVarContext, recursionCount);
1682
1653
  }
1683
1654
  }
1684
1655
  else {
1685
1656
  destType.shared.parameters.forEach((param) => {
1686
- setTypeArgumentsRecursive(param.type, srcType, typeVarContext, recursionCount);
1657
+ setTypeArgsRecursive(param.type, srcType, typeVarContext, recursionCount);
1687
1658
  });
1688
1659
  if (destType.shared.declaredReturnType) {
1689
- setTypeArgumentsRecursive(destType.shared.declaredReturnType, srcType, typeVarContext, recursionCount);
1660
+ setTypeArgsRecursive(destType.shared.declaredReturnType, srcType, typeVarContext, recursionCount);
1690
1661
  }
1691
1662
  }
1692
1663
  break;
1693
1664
  case 5 /* TypeCategory.OverloadedFunction */:
1694
1665
  destType.priv.overloads.forEach((subtype) => {
1695
- setTypeArgumentsRecursive(subtype, srcType, typeVarContext, recursionCount);
1666
+ setTypeArgsRecursive(subtype, srcType, typeVarContext, recursionCount);
1696
1667
  });
1697
1668
  break;
1698
1669
  case 9 /* TypeCategory.TypeVar */:
1699
- if (!typeVarContext.getPrimarySignature().getTypeVar(destType)) {
1700
- typeVarContext.setTypeVarType(destType, srcType);
1670
+ if (!typeVarContext.getMainSolutionSet().getTypeVar(destType)) {
1671
+ setTypeVarType(typeVarContext, destType, srcType);
1701
1672
  }
1702
1673
  break;
1703
1674
  }
1704
1675
  }
1705
- exports.setTypeArgumentsRecursive = setTypeArgumentsRecursive;
1676
+ exports.setTypeArgsRecursive = setTypeArgsRecursive;
1706
1677
  // Builds a mapping between type parameters and their specialized
1707
1678
  // types. For example, if the generic type is Dict[_T1, _T2] and the
1708
1679
  // specialized type is Dict[str, int], it returns a map that associates
1709
1680
  // _T1 with str and _T2 with int.
1710
1681
  function buildTypeVarContextFromSpecializedClass(classType) {
1711
- const typeParameters = types_1.ClassType.getTypeParameters(classType);
1712
- const typeVarContext = buildTypeVarContext(typeParameters, classType.priv.typeArguments, getTypeVarScopeId(classType));
1713
- if (types_1.ClassType.isTupleClass(classType) && classType.priv.tupleTypeArguments) {
1714
- typeVarContext.setTupleTypeVar(typeParameters[0], classType.priv.tupleTypeArguments);
1682
+ const typeParams = types_1.ClassType.getTypeParams(classType);
1683
+ let typeArgs;
1684
+ if (classType.priv.tupleTypeArgs) {
1685
+ typeArgs = [
1686
+ convertToInstance(specializeTupleClass(classType, classType.priv.tupleTypeArgs, classType.priv.isTypeArgExplicit,
1687
+ /* isUnpackedTuple */ true)),
1688
+ ];
1715
1689
  }
1716
- return typeVarContext;
1690
+ else {
1691
+ typeArgs = classType.priv.typeArgs;
1692
+ }
1693
+ return buildTypeVarContext(typeParams, typeArgs, getTypeVarScopeId(classType));
1717
1694
  }
1718
1695
  exports.buildTypeVarContextFromSpecializedClass = buildTypeVarContextFromSpecializedClass;
1719
- function buildTypeVarContext(typeParameters, typeArgs, typeVarScopeId) {
1696
+ function buildTypeVarContext(typeParams, typeArgs, typeVarScopeId) {
1720
1697
  const typeVarContext = new typeVarContext_1.TypeVarContext(typeVarScopeId);
1721
- typeParameters.forEach((typeParam, index) => {
1698
+ typeParams.forEach((typeParam, index) => {
1722
1699
  let typeArgType;
1723
1700
  if (typeArgs) {
1724
- if (typeParam.shared.isParamSpec) {
1701
+ if ((0, types_1.isParamSpec)(typeParam)) {
1725
1702
  if (index < typeArgs.length) {
1726
1703
  typeArgType = typeArgs[index];
1727
1704
  if ((0, types_1.isFunction)(typeArgType) && types_1.FunctionType.isParamSpecValue(typeArgType)) {
1728
1705
  const parameters = [];
1729
1706
  const typeArgFunctionType = typeArgType;
1730
1707
  typeArgType.shared.parameters.forEach((param, paramIndex) => {
1731
- parameters.push(types_1.FunctionParam.create(param.category, types_1.FunctionType.getEffectiveParameterType(typeArgFunctionType, paramIndex), param.flags & types_1.FunctionParamFlags.NameSynthesized, param.name, param.defaultType));
1708
+ parameters.push(types_1.FunctionParam.create(param.category, types_1.FunctionType.getEffectiveParamType(typeArgFunctionType, paramIndex), param.flags & types_1.FunctionParamFlags.NameSynthesized, param.name, param.defaultType));
1732
1709
  });
1733
- typeVarContext.setTypeVarType(typeParam, convertTypeToParamSpecValue(typeArgType));
1710
+ setTypeVarType(typeVarContext, typeParam, typeArgType);
1734
1711
  }
1735
1712
  else if ((0, types_1.isParamSpec)(typeArgType) || (0, types_1.isAnyOrUnknown)(typeArgType)) {
1736
- typeVarContext.setTypeVarType(typeParam, convertTypeToParamSpecValue(typeArgType));
1713
+ setTypeVarType(typeVarContext, typeParam, typeArgType);
1737
1714
  }
1738
1715
  }
1739
1716
  }
@@ -1744,8 +1721,8 @@ function buildTypeVarContext(typeParameters, typeArgs, typeVarScopeId) {
1744
1721
  else {
1745
1722
  typeArgType = typeArgs[index];
1746
1723
  }
1747
- typeVarContext.setTypeVarType(typeParam, typeArgType,
1748
- /* narrowBoundNoLiterals */ undefined, typeArgType);
1724
+ setTypeVarType(typeVarContext, typeParam, typeArgType,
1725
+ /* lowerBoundNoLiterals */ undefined, typeArgType);
1749
1726
  }
1750
1727
  }
1751
1728
  });
@@ -1754,7 +1731,7 @@ function buildTypeVarContext(typeParameters, typeArgs, typeVarScopeId) {
1754
1731
  exports.buildTypeVarContext = buildTypeVarContext;
1755
1732
  // Determines the specialized base class type that srcType derives from.
1756
1733
  function specializeForBaseClass(srcType, baseClass) {
1757
- const typeParams = types_1.ClassType.getTypeParameters(baseClass);
1734
+ const typeParams = types_1.ClassType.getTypeParams(baseClass);
1758
1735
  // If there are no type parameters for the specified base class,
1759
1736
  // no specialization is required.
1760
1737
  if (typeParams.length === 0) {
@@ -1799,9 +1776,9 @@ function synthesizeTypeVarForSelfCls(classType, isClsParam) {
1799
1776
  selfType.shared.isSynthesizedSelf = true;
1800
1777
  selfType.priv.nameWithScope = types_1.TypeVarType.makeNameWithScope(selfType.shared.name, scopeId);
1801
1778
  selfType.priv.scopeId = scopeId;
1802
- const boundType = types_1.ClassType.cloneForSpecialization(classType,
1803
- /* typeArguments */ undefined,
1804
- /* isTypeArgumentExplicit */ false,
1779
+ const boundType = types_1.ClassType.specialize(classType,
1780
+ /* typeArgs */ undefined,
1781
+ /* isTypeArgExplicit */ false,
1805
1782
  /* includeSubclasses */ !!classType.priv.includeSubclasses);
1806
1783
  selfType.shared.boundType = types_1.ClassType.cloneAsInstance(boundType);
1807
1784
  return isClsParam ? types_1.TypeVarType.cloneAsInstantiable(selfType) : selfType;
@@ -1838,8 +1815,8 @@ function getGeneratorYieldType(declaredReturnType, isAsync) {
1838
1815
  ['', 'AwaitableGenerator'],
1839
1816
  ];
1840
1817
  if (expectedClasses.some((classes) => types_1.ClassType.isBuiltIn(subtype, isAsync ? classes[0] : classes[1]))) {
1841
- return subtype.priv.typeArguments && subtype.priv.typeArguments.length >= 1
1842
- ? subtype.priv.typeArguments[0]
1818
+ return subtype.priv.typeArgs && subtype.priv.typeArgs.length >= 1
1819
+ ? subtype.priv.typeArgs[0]
1843
1820
  : types_1.UnknownType.create();
1844
1821
  }
1845
1822
  }
@@ -1895,17 +1872,17 @@ function convertToInstance(type, includeSubclasses = true) {
1895
1872
  // Handle type[x] as a special case.
1896
1873
  if (types_1.ClassType.isBuiltIn(subtype, 'type')) {
1897
1874
  if (types_1.TypeBase.isInstance(subtype)) {
1898
- if (!subtype.priv.typeArguments || subtype.priv.typeArguments.length < 1) {
1875
+ if (!subtype.priv.typeArgs || subtype.priv.typeArgs.length < 1) {
1899
1876
  return types_1.UnknownType.create();
1900
1877
  }
1901
1878
  else {
1902
- return subtype.priv.typeArguments[0];
1879
+ return subtype.priv.typeArgs[0];
1903
1880
  }
1904
1881
  }
1905
1882
  else {
1906
- if (subtype.priv.typeArguments && subtype.priv.typeArguments.length > 0) {
1907
- if (!(0, types_1.isAnyOrUnknown)(subtype.priv.typeArguments[0])) {
1908
- return convertToInstantiable(subtype.priv.typeArguments[0]);
1883
+ if (subtype.priv.typeArgs && subtype.priv.typeArgs.length > 0) {
1884
+ if (!(0, types_1.isAnyOrUnknown)(subtype.priv.typeArgs[0])) {
1885
+ return convertToInstantiable(subtype.priv.typeArgs[0]);
1909
1886
  }
1910
1887
  }
1911
1888
  }
@@ -1944,7 +1921,7 @@ function convertToInstance(type, includeSubclasses = true) {
1944
1921
  // Copy over any type alias information.
1945
1922
  const aliasInfo = (_b = type.props) === null || _b === void 0 ? void 0 : _b.typeAliasInfo;
1946
1923
  if (aliasInfo && type !== result) {
1947
- result = types_1.TypeBase.cloneForTypeAlias(result, aliasInfo.name, aliasInfo.fullName, aliasInfo.moduleName, aliasInfo.fileUri, aliasInfo.typeVarScopeId, aliasInfo.isPep695Syntax, aliasInfo.typeParameters, aliasInfo.typeArguments);
1924
+ result = types_1.TypeBase.cloneForTypeAlias(result, aliasInfo.name, aliasInfo.fullName, aliasInfo.moduleName, aliasInfo.fileUri, aliasInfo.typeVarScopeId, aliasInfo.isPep695Syntax, aliasInfo.typeParams, aliasInfo.typeArgs);
1948
1925
  }
1949
1926
  if (type !== result && includeSubclasses) {
1950
1927
  // Cache the converted value for next time.
@@ -2131,8 +2108,8 @@ function isPartlyUnknown(type, recursionCount = 0) {
2131
2108
  // If this is a generic type alias, see if any of its type arguments
2132
2109
  // are either unspecified or are partially known.
2133
2110
  const aliasInfo = (_a = type.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo;
2134
- if (aliasInfo === null || aliasInfo === void 0 ? void 0 : aliasInfo.typeArguments) {
2135
- if (aliasInfo.typeArguments.some((typeArg) => isPartlyUnknown(typeArg, recursionCount))) {
2111
+ if (aliasInfo === null || aliasInfo === void 0 ? void 0 : aliasInfo.typeArgs) {
2112
+ if (aliasInfo.typeArgs.some((typeArg) => isPartlyUnknown(typeArg, recursionCount))) {
2136
2113
  return true;
2137
2114
  }
2138
2115
  }
@@ -2149,7 +2126,7 @@ function isPartlyUnknown(type, recursionCount = 0) {
2149
2126
  return false;
2150
2127
  }
2151
2128
  if (!types_1.ClassType.isPseudoGenericClass(type)) {
2152
- const typeArgs = ((_b = type.priv.tupleTypeArguments) === null || _b === void 0 ? void 0 : _b.map((t) => t.type)) || type.priv.typeArguments;
2129
+ const typeArgs = ((_b = type.priv.tupleTypeArgs) === null || _b === void 0 ? void 0 : _b.map((t) => t.type)) || type.priv.typeArgs;
2153
2130
  if (typeArgs) {
2154
2131
  for (const argType of typeArgs) {
2155
2132
  if (isPartlyUnknown(argType, recursionCount)) {
@@ -2170,7 +2147,7 @@ function isPartlyUnknown(type, recursionCount = 0) {
2170
2147
  for (let i = 0; i < type.shared.parameters.length; i++) {
2171
2148
  // Ignore parameters such as "*" that have no name.
2172
2149
  if (type.shared.parameters[i].name) {
2173
- const paramType = types_1.FunctionType.getEffectiveParameterType(type, i);
2150
+ const paramType = types_1.FunctionType.getEffectiveParamType(type, i);
2174
2151
  if (isPartlyUnknown(paramType, recursionCount)) {
2175
2152
  return true;
2176
2153
  }
@@ -2190,13 +2167,11 @@ exports.isPartlyUnknown = isPartlyUnknown;
2190
2167
  // that is a union, it "explodes" the class into a union of classes with
2191
2168
  // each element of the union - e.g. Foo[A | B] becomes Foo[A] | Foo[B].
2192
2169
  function explodeGenericClass(classType) {
2193
- if (!classType.priv.typeArguments ||
2194
- classType.priv.typeArguments.length !== 1 ||
2195
- !(0, types_1.isUnion)(classType.priv.typeArguments[0])) {
2170
+ if (!classType.priv.typeArgs || classType.priv.typeArgs.length !== 1 || !(0, types_1.isUnion)(classType.priv.typeArgs[0])) {
2196
2171
  return classType;
2197
2172
  }
2198
- return (0, types_1.combineTypes)(classType.priv.typeArguments[0].priv.subtypes.map((subtype) => {
2199
- return types_1.ClassType.cloneForSpecialization(classType, [subtype], /* isTypeArgumentExplicit */ true);
2173
+ return (0, types_1.combineTypes)(classType.priv.typeArgs[0].priv.subtypes.map((subtype) => {
2174
+ return types_1.ClassType.specialize(classType, [subtype]);
2200
2175
  }));
2201
2176
  }
2202
2177
  exports.explodeGenericClass = explodeGenericClass;
@@ -2219,10 +2194,10 @@ function combineSameSizedTuples(type, tupleType) {
2219
2194
  // tuple with a known size. This includes named tuples.
2220
2195
  tupleClass = subtype.shared.mro.find((mroClass) => (0, types_1.isClass)(mroClass) && isTupleClass(mroClass) && !isUnboundedTupleClass(mroClass));
2221
2196
  }
2222
- if (tupleClass && (0, types_1.isClass)(tupleClass) && tupleClass.priv.tupleTypeArguments) {
2197
+ if (tupleClass && (0, types_1.isClass)(tupleClass) && tupleClass.priv.tupleTypeArgs) {
2223
2198
  if (tupleEntries) {
2224
- if (tupleEntries.length === tupleClass.priv.tupleTypeArguments.length) {
2225
- tupleClass.priv.tupleTypeArguments.forEach((entry, index) => {
2199
+ if (tupleEntries.length === tupleClass.priv.tupleTypeArgs.length) {
2200
+ tupleClass.priv.tupleTypeArgs.forEach((entry, index) => {
2226
2201
  tupleEntries[index].push(entry.type);
2227
2202
  });
2228
2203
  }
@@ -2231,7 +2206,7 @@ function combineSameSizedTuples(type, tupleType) {
2231
2206
  }
2232
2207
  }
2233
2208
  else {
2234
- tupleEntries = tupleClass.priv.tupleTypeArguments.map((entry) => [entry.type]);
2209
+ tupleEntries = tupleClass.priv.tupleTypeArgs.map((entry) => [entry.type]);
2235
2210
  }
2236
2211
  }
2237
2212
  else {
@@ -2250,18 +2225,21 @@ function combineSameSizedTuples(type, tupleType) {
2250
2225
  })));
2251
2226
  }
2252
2227
  exports.combineSameSizedTuples = combineSameSizedTuples;
2253
- // Tuples require special handling for specialization. This method computes
2254
- // the "effective" type argument, which is a union of the variadic type
2255
- // arguments.
2256
- function specializeTupleClass(classType, typeArgs, isTypeArgumentExplicit = true, isUnpackedTuple = false) {
2257
- const combinedTupleType = (0, types_1.combineTypes)(typeArgs.map((t) => {
2258
- if ((0, types_1.isTypeVar)(t.type) && (0, types_1.isUnpackedVariadicTypeVar)(t.type)) {
2228
+ function combineTupleTypeArgs(typeArgs) {
2229
+ return (0, types_1.combineTypes)(typeArgs.map((t) => {
2230
+ if ((0, types_1.isTypeVar)(t.type) && (0, types_1.isUnpackedTypeVarTuple)(t.type)) {
2259
2231
  // Treat the unpacked TypeVarTuple as a union.
2260
2232
  return types_1.TypeVarType.cloneForUnpacked(t.type, /* isInUnion */ true);
2261
2233
  }
2262
2234
  return t.type;
2263
2235
  }));
2264
- const clonedClassType = types_1.ClassType.cloneForSpecialization(classType, [combinedTupleType], isTypeArgumentExplicit,
2236
+ }
2237
+ exports.combineTupleTypeArgs = combineTupleTypeArgs;
2238
+ // Tuples require special handling for specialization. This method computes
2239
+ // the "effective" type argument, which is a union of the variadic type
2240
+ // arguments.
2241
+ function specializeTupleClass(classType, typeArgs, isTypeArgExplicit = true, isUnpackedTuple = false) {
2242
+ const clonedClassType = types_1.ClassType.specialize(classType, [combineTupleTypeArgs(typeArgs)], isTypeArgExplicit,
2265
2243
  /* includeSubclasses */ undefined, typeArgs);
2266
2244
  if (isUnpackedTuple) {
2267
2245
  clonedClassType.priv.isUnpacked = true;
@@ -2270,8 +2248,8 @@ function specializeTupleClass(classType, typeArgs, isTypeArgumentExplicit = true
2270
2248
  }
2271
2249
  exports.specializeTupleClass = specializeTupleClass;
2272
2250
  function _expandVariadicUnpackedUnion(type) {
2273
- if ((0, types_1.isClassInstance)(type) && isTupleClass(type) && type.priv.tupleTypeArguments && type.priv.isUnpacked) {
2274
- return (0, types_1.combineTypes)(type.priv.tupleTypeArguments.map((t) => t.type));
2251
+ if ((0, types_1.isClassInstance)(type) && isTupleClass(type) && type.priv.tupleTypeArgs && type.priv.isUnpacked) {
2252
+ return (0, types_1.combineTypes)(type.priv.tupleTypeArgs.map((t) => t.type));
2275
2253
  }
2276
2254
  return type;
2277
2255
  }
@@ -2281,20 +2259,20 @@ function getGeneratorTypeArgs(returnType) {
2281
2259
  var _a;
2282
2260
  if ((0, types_1.isClassInstance)(returnType)) {
2283
2261
  if (types_1.ClassType.isBuiltIn(returnType, ['Generator', 'AsyncGenerator'])) {
2284
- return returnType.priv.typeArguments;
2262
+ return returnType.priv.typeArgs;
2285
2263
  }
2286
2264
  else if (types_1.ClassType.isBuiltIn(returnType, 'AwaitableGenerator')) {
2287
2265
  // AwaitableGenerator has four type arguments, and the first 3
2288
2266
  // correspond to the generator.
2289
- return (_a = returnType.priv.typeArguments) === null || _a === void 0 ? void 0 : _a.slice(0, 3);
2267
+ return (_a = returnType.priv.typeArgs) === null || _a === void 0 ? void 0 : _a.slice(0, 3);
2290
2268
  }
2291
2269
  }
2292
2270
  return undefined;
2293
2271
  }
2294
2272
  exports.getGeneratorTypeArgs = getGeneratorTypeArgs;
2295
- function requiresTypeArguments(classType) {
2296
- if (classType.shared.typeParameters.length > 0) {
2297
- const firstTypeParam = classType.shared.typeParameters[0];
2273
+ function requiresTypeArgs(classType) {
2274
+ if (classType.shared.typeParams.length > 0) {
2275
+ const firstTypeParam = classType.shared.typeParams[0];
2298
2276
  // If there are type parameters, type arguments are needed.
2299
2277
  // The exception is if type parameters have been synthesized
2300
2278
  // for classes that have untyped constructors.
@@ -2309,7 +2287,7 @@ function requiresTypeArguments(classType) {
2309
2287
  return true;
2310
2288
  }
2311
2289
  // There are a few built-in special classes that require
2312
- // type arguments even though typeParameters is empty.
2290
+ // type arguments even though typeParams is empty.
2313
2291
  if (types_1.ClassType.isSpecialBuiltIn(classType)) {
2314
2292
  const specialClasses = [
2315
2293
  'Tuple',
@@ -2329,7 +2307,7 @@ function requiresTypeArguments(classType) {
2329
2307
  }
2330
2308
  return false;
2331
2309
  }
2332
- exports.requiresTypeArguments = requiresTypeArguments;
2310
+ exports.requiresTypeArgs = requiresTypeArgs;
2333
2311
  function requiresSpecialization(type, options, recursionCount = 0) {
2334
2312
  var _a;
2335
2313
  if (recursionCount > types_1.maxTypeRecursionCount) {
@@ -2362,17 +2340,17 @@ function _requiresSpecialization(type, options, recursionCount = 0) {
2362
2340
  if (types_1.ClassType.isPseudoGenericClass(type) && (options === null || options === void 0 ? void 0 : options.ignorePseudoGeneric)) {
2363
2341
  return false;
2364
2342
  }
2365
- if (!type.priv.isTypeArgumentExplicit && (options === null || options === void 0 ? void 0 : options.ignoreImplicitTypeArgs)) {
2343
+ if (!type.priv.isTypeArgExplicit && (options === null || options === void 0 ? void 0 : options.ignoreImplicitTypeArgs)) {
2366
2344
  return false;
2367
2345
  }
2368
- if (type.priv.typeArguments) {
2369
- return type.priv.typeArguments.some((typeArg) => requiresSpecialization(typeArg, options, recursionCount));
2346
+ if (type.priv.typeArgs) {
2347
+ return type.priv.typeArgs.some((typeArg) => requiresSpecialization(typeArg, options, recursionCount));
2370
2348
  }
2371
- return types_1.ClassType.getTypeParameters(type).length > 0;
2349
+ return types_1.ClassType.getTypeParams(type).length > 0;
2372
2350
  }
2373
2351
  case 4 /* TypeCategory.Function */: {
2374
2352
  for (let i = 0; i < type.shared.parameters.length; i++) {
2375
- if (requiresSpecialization(types_1.FunctionType.getEffectiveParameterType(type, i), options, recursionCount)) {
2353
+ if (requiresSpecialization(types_1.FunctionType.getEffectiveParamType(type, i), options, recursionCount)) {
2376
2354
  return true;
2377
2355
  }
2378
2356
  }
@@ -2408,8 +2386,8 @@ function _requiresSpecialization(type, options, recursionCount = 0) {
2408
2386
  // If this is a recursive type alias, it may need to be specialized
2409
2387
  // if it has generic type arguments.
2410
2388
  const aliasInfo = (_b = type.props) === null || _b === void 0 ? void 0 : _b.typeAliasInfo;
2411
- if (aliasInfo === null || aliasInfo === void 0 ? void 0 : aliasInfo.typeArguments) {
2412
- return aliasInfo.typeArguments.some((typeArg) => requiresSpecialization(typeArg, options, recursionCount));
2389
+ if (aliasInfo === null || aliasInfo === void 0 ? void 0 : aliasInfo.typeArgs) {
2390
+ return aliasInfo.typeArgs.some((typeArg) => requiresSpecialization(typeArg, options, recursionCount));
2413
2391
  }
2414
2392
  }
2415
2393
  }
@@ -2430,25 +2408,25 @@ function combineVariances(variance1, variance2) {
2430
2408
  exports.combineVariances = combineVariances;
2431
2409
  // Determines if the variance of the type argument for a generic class is compatible
2432
2410
  // With the declared variance of the corresponding type parameter.
2433
- function isVarianceOfTypeArgumentCompatible(type, typeParamVariance) {
2411
+ function isVarianceOfTypeArgCompatible(type, typeParamVariance) {
2434
2412
  if (typeParamVariance === 1 /* Variance.Unknown */ || typeParamVariance === 0 /* Variance.Auto */) {
2435
2413
  return true;
2436
2414
  }
2437
- if ((0, types_1.isTypeVar)(type) && !type.shared.isParamSpec && !type.shared.isVariadic) {
2415
+ if ((0, types_1.isTypeVar)(type) && !(0, types_1.isParamSpec)(type) && !(0, types_1.isTypeVarTuple)(type)) {
2438
2416
  const typeArgVariance = type.shared.declaredVariance;
2439
2417
  if (typeArgVariance === 4 /* Variance.Contravariant */ || typeArgVariance === 3 /* Variance.Covariant */) {
2440
2418
  return typeArgVariance === typeParamVariance;
2441
2419
  }
2442
2420
  }
2443
2421
  else if ((0, types_1.isClassInstance)(type)) {
2444
- if (type.shared.typeParameters && type.shared.typeParameters.length > 0) {
2445
- return type.shared.typeParameters.every((typeParam, index) => {
2422
+ if (type.shared.typeParams && type.shared.typeParams.length > 0) {
2423
+ return type.shared.typeParams.every((typeParam, index) => {
2446
2424
  let typeArgType;
2447
- if (typeParam.shared.isParamSpec || typeParam.shared.isVariadic) {
2425
+ if ((0, types_1.isParamSpec)(typeParam) || (0, types_1.isTypeVarTuple)(typeParam)) {
2448
2426
  return true;
2449
2427
  }
2450
- if (type.priv.typeArguments && index < type.priv.typeArguments.length) {
2451
- typeArgType = type.priv.typeArguments[index];
2428
+ if (type.priv.typeArgs && index < type.priv.typeArgs.length) {
2429
+ typeArgType = type.priv.typeArgs[index];
2452
2430
  }
2453
2431
  const declaredVariance = typeParam.shared.declaredVariance;
2454
2432
  if (declaredVariance === 0 /* Variance.Auto */) {
@@ -2470,13 +2448,13 @@ function isVarianceOfTypeArgumentCompatible(type, typeParamVariance) {
2470
2448
  effectiveVariance = 3 /* Variance.Covariant */;
2471
2449
  }
2472
2450
  }
2473
- return isVarianceOfTypeArgumentCompatible(typeArgType !== null && typeArgType !== void 0 ? typeArgType : types_1.UnknownType.create(), effectiveVariance);
2451
+ return isVarianceOfTypeArgCompatible(typeArgType !== null && typeArgType !== void 0 ? typeArgType : types_1.UnknownType.create(), effectiveVariance);
2474
2452
  });
2475
2453
  }
2476
2454
  }
2477
2455
  return true;
2478
2456
  }
2479
- exports.isVarianceOfTypeArgumentCompatible = isVarianceOfTypeArgumentCompatible;
2457
+ exports.isVarianceOfTypeArgCompatible = isVarianceOfTypeArgCompatible;
2480
2458
  // Computes the method resolution ordering for a class whose base classes
2481
2459
  // have already been filled in. The algorithm for computing MRO is described
2482
2460
  // here: https://www.python.org/download/releases/2.3/mro/. It returns true
@@ -2501,8 +2479,8 @@ function computeMroLinearization(classType) {
2501
2479
  if (classType.shared.baseClasses.some((innerBaseClass, innerIndex) => {
2502
2480
  return (innerIndex > index &&
2503
2481
  (0, types_1.isInstantiableClass)(innerBaseClass) &&
2504
- innerBaseClass.priv.typeArguments &&
2505
- innerBaseClass.priv.isTypeArgumentExplicit);
2482
+ innerBaseClass.priv.typeArgs &&
2483
+ innerBaseClass.priv.isTypeArgExplicit);
2506
2484
  })) {
2507
2485
  return false;
2508
2486
  }
@@ -2616,14 +2594,14 @@ function getDeclaringModulesForType(type) {
2616
2594
  return moduleList;
2617
2595
  }
2618
2596
  exports.getDeclaringModulesForType = getDeclaringModulesForType;
2619
- function convertArgumentNodeToFunctionArgument(node) {
2597
+ function convertNodeToArg(node) {
2620
2598
  return {
2621
- argumentCategory: node.d.argCategory,
2599
+ argCategory: node.d.argCategory,
2622
2600
  name: node.d.name,
2623
2601
  valueExpression: node.d.valueExpr,
2624
2602
  };
2625
2603
  }
2626
- exports.convertArgumentNodeToFunctionArgument = convertArgumentNodeToFunctionArgument;
2604
+ exports.convertNodeToArg = convertNodeToArg;
2627
2605
  function addDeclaringModuleNamesForType(type, moduleList, recursionCount = 0) {
2628
2606
  if (recursionCount > types_1.maxTypeRecursionCount) {
2629
2607
  return;
@@ -2675,7 +2653,7 @@ function convertTypeToParamSpecValue(type) {
2675
2653
  const newFunction = types_1.FunctionType.createInstance('', '', '', type.shared.flags | 65536 /* FunctionTypeFlags.ParamSpecValue */, type.shared.docString);
2676
2654
  newFunction.shared.deprecatedMessage = type.shared.deprecatedMessage;
2677
2655
  type.shared.parameters.forEach((param, index) => {
2678
- 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));
2656
+ types_1.FunctionType.addParam(newFunction, types_1.FunctionParam.create(param.category, types_1.FunctionType.getEffectiveParamType(type, index), param.flags & types_1.FunctionParamFlags.NameSynthesized, param.name, param.defaultType));
2679
2657
  });
2680
2658
  if (type.priv.higherOrderTypeVarScopeIds) {
2681
2659
  newFunction.priv.higherOrderTypeVarScopeIds = [...type.priv.higherOrderTypeVarScopeIds];
@@ -2684,25 +2662,42 @@ function convertTypeToParamSpecValue(type) {
2684
2662
  newFunction.priv.constructorTypeVarScopeId = type.priv.constructorTypeVarScopeId;
2685
2663
  return newFunction;
2686
2664
  }
2687
- return getUnknownTypeForParamSpec();
2665
+ return types_1.ParamSpecType.getUnknown();
2688
2666
  }
2689
2667
  exports.convertTypeToParamSpecValue = convertTypeToParamSpecValue;
2668
+ // This function calls the setTypeVarType method on the TypeVarContext after
2669
+ // converting the parameters for use with a ParamSpec.
2670
+ function setTypeVarType(typeVarContext, typeVar, lowerBound, lowerBoundNoLiterals, upperBound) {
2671
+ if ((0, types_1.isParamSpec)(typeVar)) {
2672
+ if (lowerBound) {
2673
+ lowerBound = convertTypeToParamSpecValue(lowerBound);
2674
+ }
2675
+ if (lowerBoundNoLiterals) {
2676
+ lowerBoundNoLiterals = convertTypeToParamSpecValue(lowerBoundNoLiterals);
2677
+ }
2678
+ if (upperBound) {
2679
+ lowerBound = convertTypeToParamSpecValue(upperBound);
2680
+ }
2681
+ }
2682
+ typeVarContext.setTypeVarType(typeVar, lowerBound, lowerBoundNoLiterals, upperBound);
2683
+ }
2684
+ exports.setTypeVarType = setTypeVarType;
2690
2685
  // Converts a FunctionType into a ParamSpec if it consists only of
2691
2686
  // (* args: P.args, ** kwargs: P.kwargs). Otherwise returns the original type.
2692
2687
  function convertParamSpecValueToType(type) {
2693
2688
  const paramSpec = types_1.FunctionType.getParamSpecFromArgsKwargs(type);
2694
2689
  const withoutParamSpec = types_1.FunctionType.cloneRemoveParamSpecArgsKwargs(type);
2695
- let hasParameters = withoutParamSpec.shared.parameters.length > 0;
2690
+ let hasParams = withoutParamSpec.shared.parameters.length > 0;
2696
2691
  if (withoutParamSpec.shared.parameters.length === 1) {
2697
2692
  // If the ParamSpec has a position-only separator as its only parameter,
2698
2693
  // treat it as though there are no parameters.
2699
2694
  const onlyParam = withoutParamSpec.shared.parameters[0];
2700
2695
  if ((0, types_1.isPositionOnlySeparator)(onlyParam)) {
2701
- hasParameters = false;
2696
+ hasParams = false;
2702
2697
  }
2703
2698
  }
2704
2699
  // Can we simplify it to just a paramSpec?
2705
- if (!hasParameters && paramSpec) {
2700
+ if (!hasParams && paramSpec) {
2706
2701
  return paramSpec;
2707
2702
  }
2708
2703
  // Create a function type from the param spec entries.
@@ -2711,7 +2706,7 @@ function convertParamSpecValueToType(type) {
2711
2706
  types_1.FunctionType.addHigherOrderTypeVarScopeIds(functionType, withoutParamSpec.priv.higherOrderTypeVarScopeIds);
2712
2707
  functionType.priv.constructorTypeVarScopeId = withoutParamSpec.priv.constructorTypeVarScopeId;
2713
2708
  withoutParamSpec.shared.parameters.forEach((entry, index) => {
2714
- 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));
2709
+ types_1.FunctionType.addParam(functionType, types_1.FunctionParam.create(entry.category, types_1.FunctionType.getEffectiveParamType(withoutParamSpec, index), (entry.flags & types_1.FunctionParamFlags.NameSynthesized) | types_1.FunctionParamFlags.TypeDeclared, entry.name, entry.defaultType));
2715
2710
  });
2716
2711
  if (paramSpec) {
2717
2712
  types_1.FunctionType.addParamSpecVariadics(functionType, paramSpec);
@@ -2758,11 +2753,11 @@ class TypeVarTransformer {
2758
2753
  // type aliases.
2759
2754
  const aliasInfo = (_b = type.props) === null || _b === void 0 ? void 0 : _b.typeAliasInfo;
2760
2755
  if (type.shared.recursiveAlias) {
2761
- if (!(aliasInfo === null || aliasInfo === void 0 ? void 0 : aliasInfo.typeArguments)) {
2756
+ if (!(aliasInfo === null || aliasInfo === void 0 ? void 0 : aliasInfo.typeArgs)) {
2762
2757
  return type;
2763
2758
  }
2764
2759
  let requiresUpdate = false;
2765
- const typeArgs = aliasInfo.typeArguments.map((typeArg) => {
2760
+ const typeArgs = aliasInfo.typeArgs.map((typeArg) => {
2766
2761
  const replacementType = this.apply(typeArg, recursionCount);
2767
2762
  if (replacementType !== typeArg) {
2768
2763
  requiresUpdate = true;
@@ -2770,7 +2765,7 @@ class TypeVarTransformer {
2770
2765
  return replacementType;
2771
2766
  });
2772
2767
  if (requiresUpdate) {
2773
- return types_1.TypeBase.cloneForTypeAlias(type, aliasInfo.name, aliasInfo.fullName, aliasInfo.moduleName, aliasInfo.fileUri, aliasInfo.typeVarScopeId, aliasInfo.isPep695Syntax, aliasInfo.typeParameters, typeArgs);
2768
+ return types_1.TypeBase.cloneForTypeAlias(type, aliasInfo.name, aliasInfo.fullName, aliasInfo.moduleName, aliasInfo.fileUri, aliasInfo.typeVarScopeId, aliasInfo.isPep695Syntax, aliasInfo.typeParams, typeArgs);
2774
2769
  }
2775
2770
  return type;
2776
2771
  }
@@ -2779,9 +2774,9 @@ class TypeVarTransformer {
2779
2774
  // type variables in the same scope recursively by setting it the scope in the
2780
2775
  // _pendingTypeVarTransformations set.
2781
2776
  if (!this._isTypeVarScopePending(type.priv.scopeId)) {
2782
- if (type.shared.isParamSpec) {
2777
+ if ((0, types_1.isParamSpec)(type)) {
2783
2778
  let paramSpecWithoutAccess = type;
2784
- if (type.priv.paramSpecAccess) {
2779
+ if ((0, types_1.isParamSpec)(type) && type.priv.paramSpecAccess) {
2785
2780
  paramSpecWithoutAccess = types_1.TypeVarType.cloneForParamSpecAccess(type, /* access */ undefined);
2786
2781
  }
2787
2782
  const paramSpecValue = this.transformParamSpec(paramSpecWithoutAccess, recursionCount);
@@ -2813,7 +2808,7 @@ class TypeVarTransformer {
2813
2808
  }
2814
2809
  // If we're transforming a variadic type variable that was in a union,
2815
2810
  // expand the union types.
2816
- if ((0, types_1.isVariadicTypeVar)(type) && type.priv.isVariadicInUnion) {
2811
+ if ((0, types_1.isTypeVarTuple)(type) && type.priv.isVariadicInUnion) {
2817
2812
  replacementType = _expandVariadicUnpackedUnion(replacementType);
2818
2813
  }
2819
2814
  }
@@ -2825,7 +2820,7 @@ class TypeVarTransformer {
2825
2820
  let transformedType = this.apply(subtype, recursionCount);
2826
2821
  // If we're transforming a variadic type variable within a union,
2827
2822
  // combine the individual types within the variadic type variable.
2828
- if ((0, types_1.isVariadicTypeVar)(subtype) && !(0, types_1.isVariadicTypeVar)(transformedType)) {
2823
+ if ((0, types_1.isTypeVarTuple)(subtype) && !(0, types_1.isTypeVarTuple)(transformedType)) {
2829
2824
  const subtypesToCombine = [];
2830
2825
  doForEachSubtype(transformedType, (transformedSubtype) => {
2831
2826
  subtypesToCombine.push(_expandVariadicUnpackedUnion(transformedSubtype));
@@ -2891,7 +2886,7 @@ class TypeVarTransformer {
2891
2886
  transformUnionSubtype(preTransform, postTransform, recursionCount) {
2892
2887
  return postTransform;
2893
2888
  }
2894
- doForEachSignatureContext(callback) {
2889
+ doForEachSolutionSet(callback) {
2895
2890
  // By default, simply return the result of the callback. Subclasses
2896
2891
  // can override this method as they see fit.
2897
2892
  return callback();
@@ -2899,11 +2894,11 @@ class TypeVarTransformer {
2899
2894
  transformGenericTypeAlias(type, recursionCount) {
2900
2895
  var _a;
2901
2896
  const aliasInfo = (_a = type.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo;
2902
- if (!aliasInfo || !aliasInfo.typeParameters || !aliasInfo.typeArguments) {
2897
+ if (!aliasInfo || !aliasInfo.typeParams || !aliasInfo.typeArgs) {
2903
2898
  return type;
2904
2899
  }
2905
2900
  let requiresUpdate = false;
2906
- const newTypeArgs = aliasInfo.typeArguments.map((typeArg) => {
2901
+ const newTypeArgs = aliasInfo.typeArgs.map((typeArg) => {
2907
2902
  const updatedType = this.apply(typeArg, recursionCount);
2908
2903
  if (type !== updatedType) {
2909
2904
  requiresUpdate = true;
@@ -2911,7 +2906,7 @@ class TypeVarTransformer {
2911
2906
  return updatedType;
2912
2907
  });
2913
2908
  return requiresUpdate
2914
- ? types_1.TypeBase.cloneForTypeAlias(type, aliasInfo.name, aliasInfo.fullName, aliasInfo.moduleName, aliasInfo.fileUri, aliasInfo.typeVarScopeId, aliasInfo.isPep695Syntax, aliasInfo.typeParameters, newTypeArgs)
2909
+ ? types_1.TypeBase.cloneForTypeAlias(type, aliasInfo.name, aliasInfo.fullName, aliasInfo.moduleName, aliasInfo.fileUri, aliasInfo.typeVarScopeId, aliasInfo.isPep695Syntax, aliasInfo.typeParams, newTypeArgs)
2915
2910
  : type;
2916
2911
  }
2917
2912
  transformConditionalType(type, recursionCount) {
@@ -2919,7 +2914,7 @@ class TypeVarTransformer {
2919
2914
  return type;
2920
2915
  }
2921
2916
  transformTypeVarsInClassType(classType, recursionCount) {
2922
- const typeParams = types_1.ClassType.getTypeParameters(classType);
2917
+ const typeParams = types_1.ClassType.getTypeParams(classType);
2923
2918
  // Handle the common case where the class has no type parameters.
2924
2919
  if (typeParams.length === 0 &&
2925
2920
  !types_1.ClassType.isSpecialBuiltIn(classType) &&
@@ -2944,18 +2939,18 @@ class TypeVarTransformer {
2944
2939
  // If type args were previously provided, specialize them.
2945
2940
  // Handle tuples specially.
2946
2941
  if (types_1.ClassType.isTupleClass(classType)) {
2947
- if (classType.priv.tupleTypeArguments) {
2942
+ if (classType.priv.tupleTypeArgs) {
2948
2943
  newTupleTypeArgs = [];
2949
- classType.priv.tupleTypeArguments.forEach((oldTypeArgType) => {
2944
+ classType.priv.tupleTypeArgs.forEach((oldTypeArgType) => {
2950
2945
  const newTypeArgType = this.apply(oldTypeArgType.type, recursionCount);
2951
2946
  if (newTypeArgType !== oldTypeArgType.type) {
2952
2947
  specializationNeeded = true;
2953
2948
  }
2954
- if ((0, types_1.isUnpackedVariadicTypeVar)(oldTypeArgType.type) &&
2949
+ if ((0, types_1.isUnpackedTypeVarTuple)(oldTypeArgType.type) &&
2955
2950
  (0, types_1.isClassInstance)(newTypeArgType) &&
2956
2951
  isTupleClass(newTypeArgType) &&
2957
- newTypeArgType.priv.tupleTypeArguments) {
2958
- (0, collectionUtils_1.appendArray)(newTupleTypeArgs, newTypeArgType.priv.tupleTypeArguments);
2952
+ newTypeArgType.priv.tupleTypeArgs) {
2953
+ (0, collectionUtils_1.appendArray)(newTupleTypeArgs, newTypeArgType.priv.tupleTypeArgs);
2959
2954
  }
2960
2955
  else {
2961
2956
  // Handle the special case where tuple[T, ...] is being specialized
@@ -2963,7 +2958,7 @@ class TypeVarTransformer {
2963
2958
  const isEmptyTuple = oldTypeArgType.isUnbounded &&
2964
2959
  (0, types_1.isTypeVar)(oldTypeArgType.type) &&
2965
2960
  (0, types_1.isNever)(newTypeArgType) &&
2966
- classType.priv.tupleTypeArguments.length === 1;
2961
+ classType.priv.tupleTypeArgs.length === 1;
2967
2962
  if (!isEmptyTuple) {
2968
2963
  newTupleTypeArgs.push({
2969
2964
  type: newTypeArgType,
@@ -2988,21 +2983,13 @@ class TypeVarTransformer {
2988
2983
  // If this is an empty tuple, don't recompute the non-tuple type argument.
2989
2984
  if (newTupleTypeArgs && newTupleTypeArgs.length > 0) {
2990
2985
  // Combine the tuple type args into a single non-tuple type argument.
2991
- newTypeArgs = [
2992
- (0, types_1.combineTypes)(newTupleTypeArgs.map((t) => {
2993
- if ((0, types_1.isTypeVar)(t.type) && (0, types_1.isUnpackedVariadicTypeVar)(t.type)) {
2994
- // Treat the unpacked TypeVarTuple as a union.
2995
- return types_1.TypeVarType.cloneForUnpacked(t.type, /* isInUnion */ true);
2996
- }
2997
- return t.type;
2998
- })),
2999
- ];
2986
+ newTypeArgs = [combineTupleTypeArgs(newTupleTypeArgs)];
3000
2987
  }
3001
2988
  }
3002
2989
  if (!newTypeArgs) {
3003
- if (classType.priv.typeArguments) {
3004
- newTypeArgs = classType.priv.typeArguments.map((oldTypeArgType) => {
3005
- if ((0, types_1.isTypeVar)(oldTypeArgType) && oldTypeArgType.shared.isParamSpec) {
2990
+ if (classType.priv.typeArgs) {
2991
+ newTypeArgs = classType.priv.typeArgs.map((oldTypeArgType) => {
2992
+ if ((0, types_1.isParamSpec)(oldTypeArgType)) {
3006
2993
  return transformParamSpec(oldTypeArgType);
3007
2994
  }
3008
2995
  let newTypeArgType = this.apply(oldTypeArgType, recursionCount);
@@ -3011,7 +2998,7 @@ class TypeVarTransformer {
3011
2998
  // If this was a variadic type variable that was part of a union
3012
2999
  // (e.g. Union[Unpack[Vs]]), expand the subtypes into a union here.
3013
3000
  if ((0, types_1.isTypeVar)(oldTypeArgType) &&
3014
- (0, types_1.isVariadicTypeVar)(oldTypeArgType) &&
3001
+ (0, types_1.isTypeVarTuple)(oldTypeArgType) &&
3015
3002
  oldTypeArgType.priv.isVariadicInUnion) {
3016
3003
  newTypeArgType = _expandVariadicUnpackedUnion(newTypeArgType);
3017
3004
  }
@@ -3023,7 +3010,7 @@ class TypeVarTransformer {
3023
3010
  newTypeArgs = [];
3024
3011
  typeParams.forEach((typeParam) => {
3025
3012
  let replacementType = typeParam;
3026
- if (typeParam.shared.isParamSpec) {
3013
+ if ((0, types_1.isParamSpec)(typeParam)) {
3027
3014
  replacementType = transformParamSpec(typeParam);
3028
3015
  if (replacementType !== typeParam) {
3029
3016
  specializationNeeded = true;
@@ -3036,7 +3023,7 @@ class TypeVarTransformer {
3036
3023
  if (replacementType !== typeParam) {
3037
3024
  specializationNeeded = true;
3038
3025
  }
3039
- else if (transformedType !== undefined && !classType.priv.typeArguments) {
3026
+ else if (transformedType !== undefined && !classType.priv.typeArgs) {
3040
3027
  specializationNeeded = true;
3041
3028
  }
3042
3029
  }
@@ -3050,19 +3037,19 @@ class TypeVarTransformer {
3050
3037
  if (!specializationNeeded) {
3051
3038
  return classType;
3052
3039
  }
3053
- return types_1.ClassType.cloneForSpecialization(classType, newTypeArgs,
3054
- /* isTypeArgumentExplicit */ true,
3040
+ return types_1.ClassType.specialize(classType, newTypeArgs,
3041
+ /* isTypeArgExplicit */ true,
3055
3042
  /* includeSubclasses */ undefined, newTupleTypeArgs);
3056
3043
  }
3057
3044
  transformTypeVarsInFunctionType(sourceType, recursionCount) {
3058
- return this.doForEachSignatureContext(() => {
3045
+ return this.doForEachSolutionSet(() => {
3059
3046
  let functionType = sourceType;
3060
3047
  const declaredReturnType = types_1.FunctionType.getEffectiveReturnType(functionType);
3061
3048
  const specializedReturnType = declaredReturnType
3062
3049
  ? this.apply(declaredReturnType, recursionCount)
3063
3050
  : undefined;
3064
3051
  let typesRequiredSpecialization = declaredReturnType !== specializedReturnType;
3065
- const specializedParameters = {
3052
+ const specializedParams = {
3066
3053
  parameterTypes: [],
3067
3054
  parameterDefaultArgs: undefined,
3068
3055
  returnType: specializedReturnType,
@@ -3085,11 +3072,11 @@ class TypeVarTransformer {
3085
3072
  const wasTransformingTypeArg = this._isTransformingTypeArg;
3086
3073
  this._isTransformingTypeArg = true;
3087
3074
  for (let i = 0; i < functionType.shared.parameters.length; i++) {
3088
- const paramType = types_1.FunctionType.getEffectiveParameterType(functionType, i);
3075
+ const paramType = types_1.FunctionType.getEffectiveParamType(functionType, i);
3089
3076
  const specializedType = this.apply(paramType, recursionCount);
3090
- specializedParameters.parameterTypes.push(specializedType);
3077
+ specializedParams.parameterTypes.push(specializedType);
3091
3078
  // Do we need to specialize the default argument type for this parameter?
3092
- let defaultArgType = types_1.FunctionType.getEffectiveParameterDefaultArgType(functionType, i);
3079
+ let defaultArgType = types_1.FunctionType.getEffectiveParamDefaultArgType(functionType, i);
3093
3080
  if (defaultArgType) {
3094
3081
  const specializedArgType = this.apply(defaultArgType, recursionCount);
3095
3082
  if (specializedArgType !== defaultArgType) {
@@ -3099,13 +3086,13 @@ class TypeVarTransformer {
3099
3086
  }
3100
3087
  specializedDefaultArgs.push(defaultArgType);
3101
3088
  if (variadicParamIndex === undefined &&
3102
- (0, types_1.isVariadicTypeVar)(paramType) &&
3103
- functionType.shared.parameters[i].category === 1 /* ParameterCategory.ArgsList */) {
3089
+ (0, types_1.isTypeVarTuple)(paramType) &&
3090
+ functionType.shared.parameters[i].category === 1 /* ParamCategory.ArgsList */) {
3104
3091
  variadicParamIndex = i;
3105
3092
  if ((0, types_1.isClassInstance)(specializedType) &&
3106
3093
  isTupleClass(specializedType) &&
3107
3094
  specializedType.priv.isUnpacked) {
3108
- variadicTypesToUnpack = specializedType.priv.tupleTypeArguments;
3095
+ variadicTypesToUnpack = specializedType.priv.tupleTypeArgs;
3109
3096
  }
3110
3097
  }
3111
3098
  if (paramType !== specializedType) {
@@ -3139,11 +3126,11 @@ class TypeVarTransformer {
3139
3126
  return functionType;
3140
3127
  }
3141
3128
  if (specializedDefaultArgs.some((t) => t !== undefined)) {
3142
- specializedParameters.parameterDefaultArgs = specializedDefaultArgs;
3129
+ specializedParams.parameterDefaultArgs = specializedDefaultArgs;
3143
3130
  }
3144
3131
  // If there was no unpacked variadic type variable, we're done.
3145
3132
  if (!variadicTypesToUnpack) {
3146
- return types_1.FunctionType.cloneForSpecialization(functionType, specializedParameters, specializedInferredReturnType);
3133
+ return types_1.FunctionType.specialize(functionType, specializedParams, specializedInferredReturnType);
3147
3134
  }
3148
3135
  // Unpack the tuple and synthesize a new function in the process.
3149
3136
  const newFunctionType = types_1.TypeBase.isInstantiable(functionType)
@@ -3151,14 +3138,14 @@ class TypeVarTransformer {
3151
3138
  : types_1.FunctionType.createSynthesizedInstance('', functionType.shared.flags);
3152
3139
  let insertKeywordOnlySeparator = false;
3153
3140
  let swallowPositionOnlySeparator = false;
3154
- specializedParameters.parameterTypes.forEach((paramType, index) => {
3141
+ specializedParams.parameterTypes.forEach((paramType, index) => {
3155
3142
  if (index === variadicParamIndex) {
3156
3143
  let sawUnboundedEntry = false;
3157
3144
  // Unpack the tuple into individual parameters.
3158
3145
  variadicTypesToUnpack.forEach((unpackedType) => {
3159
- types_1.FunctionType.addParameter(newFunctionType, types_1.FunctionParam.create(unpackedType.isUnbounded || (0, types_1.isVariadicTypeVar)(unpackedType.type)
3160
- ? 1 /* ParameterCategory.ArgsList */
3161
- : 0 /* ParameterCategory.Simple */, unpackedType.type, types_1.FunctionParamFlags.NameSynthesized | types_1.FunctionParamFlags.TypeDeclared, `__p${newFunctionType.shared.parameters.length}`));
3146
+ types_1.FunctionType.addParam(newFunctionType, types_1.FunctionParam.create(unpackedType.isUnbounded || (0, types_1.isTypeVarTuple)(unpackedType.type)
3147
+ ? 1 /* ParamCategory.ArgsList */
3148
+ : 0 /* ParamCategory.Simple */, unpackedType.type, types_1.FunctionParamFlags.NameSynthesized | types_1.FunctionParamFlags.TypeDeclared, `__p${newFunctionType.shared.parameters.length}`));
3162
3149
  if (unpackedType.isUnbounded) {
3163
3150
  sawUnboundedEntry = true;
3164
3151
  }
@@ -3175,25 +3162,25 @@ class TypeVarTransformer {
3175
3162
  if ((0, types_1.isKeywordOnlySeparator)(param)) {
3176
3163
  insertKeywordOnlySeparator = false;
3177
3164
  }
3178
- else if (param.category === 2 /* ParameterCategory.KwargsDict */) {
3165
+ else if (param.category === 2 /* ParamCategory.KwargsDict */) {
3179
3166
  insertKeywordOnlySeparator = false;
3180
3167
  }
3181
3168
  // Insert a keyword-only separator parameter if we previously
3182
3169
  // unpacked a variadic TypeVar.
3183
- if (param.category === 0 /* ParameterCategory.Simple */ && param.name && insertKeywordOnlySeparator) {
3184
- types_1.FunctionType.addKeywordOnlyParameterSeparator(newFunctionType);
3170
+ if (param.category === 0 /* ParamCategory.Simple */ && param.name && insertKeywordOnlySeparator) {
3171
+ types_1.FunctionType.addKeywordOnlyParamSeparator(newFunctionType);
3185
3172
  insertKeywordOnlySeparator = false;
3186
3173
  }
3187
3174
  param.type = paramType;
3188
3175
  if (param.name && types_1.FunctionParam.isNameSynthesized(param)) {
3189
3176
  param.name = `__p${newFunctionType.shared.parameters.length}`;
3190
3177
  }
3191
- if (param.category !== 0 /* ParameterCategory.Simple */ || param.name || !swallowPositionOnlySeparator) {
3192
- types_1.FunctionType.addParameter(newFunctionType, param);
3178
+ if (param.category !== 0 /* ParamCategory.Simple */ || param.name || !swallowPositionOnlySeparator) {
3179
+ types_1.FunctionType.addParam(newFunctionType, param);
3193
3180
  }
3194
3181
  }
3195
3182
  });
3196
- newFunctionType.shared.declaredReturnType = specializedParameters.returnType;
3183
+ newFunctionType.shared.declaredReturnType = specializedParams.returnType;
3197
3184
  return newFunctionType;
3198
3185
  });
3199
3186
  }
@@ -3210,7 +3197,7 @@ class TypeVarAnyReplacer extends TypeVarTransformer {
3210
3197
  return types_1.AnyType.create();
3211
3198
  }
3212
3199
  transformParamSpec(paramSpec) {
3213
- return getUnknownTypeForParamSpec();
3200
+ return types_1.ParamSpecType.getUnknown();
3214
3201
  }
3215
3202
  }
3216
3203
  // For a TypeVar with a default type, validates whether the default type is using
@@ -3252,7 +3239,7 @@ class UniqueFunctionSignatureTransformer extends TypeVarTransformer {
3252
3239
  }
3253
3240
  transformTypeVarsInFunctionType(sourceType, recursionCount) {
3254
3241
  // If this function is not generic, there's no need to check for uniqueness.
3255
- if (sourceType.shared.typeParameters.length === 0) {
3242
+ if (sourceType.shared.typeParams.length === 0) {
3256
3243
  return super.transformTypeVarsInFunctionType(sourceType, recursionCount);
3257
3244
  }
3258
3245
  let updatedSourceType = sourceType;
@@ -3266,13 +3253,10 @@ class UniqueFunctionSignatureTransformer extends TypeVarTransformer {
3266
3253
  const typeVarContext = new typeVarContext_1.TypeVarContext(getTypeVarScopeIds(sourceType));
3267
3254
  // Create new type variables with the same scope but with
3268
3255
  // different (unique) names.
3269
- sourceType.shared.typeParameters.forEach((typeParam) => {
3256
+ sourceType.shared.typeParams.forEach((typeParam) => {
3270
3257
  if (typeParam.priv.scopeType === 1 /* TypeVarScopeType.Function */) {
3271
- let replacement = types_1.TypeVarType.cloneForNewName(typeParam, `${typeParam.shared.name}(${offsetIndex})`);
3272
- if (replacement.shared.isParamSpec) {
3273
- replacement = convertTypeToParamSpecValue(replacement);
3274
- }
3275
- typeVarContext.setTypeVarType(typeParam, replacement);
3258
+ const replacement = types_1.TypeVarType.cloneForNewName(typeParam, `${typeParam.shared.name}(${offsetIndex})`);
3259
+ setTypeVarType(typeVarContext, typeParam, replacement);
3276
3260
  }
3277
3261
  });
3278
3262
  updatedSourceType = applySolvedTypeVars(sourceType, typeVarContext);
@@ -3346,16 +3330,16 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
3346
3330
  }
3347
3331
  transformTypeVar(typeVar, recursionCount) {
3348
3332
  var _a, _b;
3349
- const signatureContext = this._typeVarContext.getSignatureContext((_a = this._activeTypeVarSignatureContextIndex) !== null && _a !== void 0 ? _a : 0);
3333
+ const solutionSet = this._typeVarContext.getSolutionSet((_a = this._activeSolutionSetIndex) !== null && _a !== void 0 ? _a : 0);
3350
3334
  // If the type variable is unrelated to the scopes we're solving,
3351
3335
  // don't transform that type variable.
3352
3336
  if (typeVar.priv.scopeId && this._typeVarContext.hasSolveForScope(typeVar.priv.scopeId)) {
3353
- let replacement = signatureContext.getTypeVarType(typeVar, !!this._options.useNarrowBoundOnly);
3354
- // If there was no narrow bound but there is a wide bound that
3355
- // contains literals or a TypeVar, we'll use the wide bound even if
3356
- // "useNarrowBoundOnly" is specified.
3357
- if (!replacement && this._options.useNarrowBoundOnly) {
3358
- const wideType = signatureContext.getTypeVarType(typeVar);
3337
+ let replacement = solutionSet.getTypeVarType(typeVar, !!this._options.useLowerBoundOnly);
3338
+ // If there was no lower bound but there is an upper bound that
3339
+ // contains literals or a TypeVar, we'll use the upper bound even if
3340
+ // "useLowerBoundOnly" is specified.
3341
+ if (!replacement && this._options.useLowerBoundOnly) {
3342
+ const wideType = solutionSet.getTypeVarType(typeVar);
3359
3343
  if (wideType) {
3360
3344
  if ((0, types_1.isTypeVar)(wideType) || containsLiteralType(wideType, /* includeTypeArgs */ true)) {
3361
3345
  replacement = wideType;
@@ -3367,8 +3351,9 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
3367
3351
  if ((0, types_1.isAnyOrUnknown)(replacement) &&
3368
3352
  this._options.typeClassType &&
3369
3353
  (0, types_1.isInstantiableClass)(this._options.typeClassType)) {
3370
- replacement = types_1.ClassType.cloneForSpecialization(types_1.ClassType.cloneAsInstance(this._options.typeClassType), [replacement],
3371
- /* isTypeArgumentExplicit */ true);
3354
+ replacement = types_1.ClassType.specialize(types_1.ClassType.cloneAsInstance(this._options.typeClassType), [
3355
+ replacement,
3356
+ ]);
3372
3357
  }
3373
3358
  else {
3374
3359
  replacement = convertToInstantiable(replacement, /* includeSubclasses */ false);
@@ -3386,7 +3371,7 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
3386
3371
  if (!subtype.priv.includeSubclasses) {
3387
3372
  subtype = types_1.ClassType.cloneAsInstance(types_1.ClassType.cloneAsInstantiable(subtype));
3388
3373
  }
3389
- if (subtype.shared.typeParameters && !subtype.priv.typeArguments) {
3374
+ if (subtype.shared.typeParams && !subtype.priv.typeArgs) {
3390
3375
  if (this._options.unknownIfNotFound) {
3391
3376
  return this._options.useUnknownOverDefault
3392
3377
  ? specializeWithUnknownTypeArgs(subtype, this._options.tupleClassType)
@@ -3397,9 +3382,17 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
3397
3382
  return subtype;
3398
3383
  });
3399
3384
  }
3400
- if ((0, types_1.isTypeVar)(replacement) && typeVar.priv.isVariadicUnpacked && replacement.shared.isVariadic) {
3385
+ if ((0, types_1.isTypeVarTuple)(replacement) && (0, types_1.isTypeVarTuple)(typeVar) && typeVar.priv.isVariadicUnpacked) {
3401
3386
  return types_1.TypeVarType.cloneForUnpacked(replacement, typeVar.priv.isVariadicInUnion);
3402
3387
  }
3388
+ // If this isn't a variadic typeVar, combine all of the tuple
3389
+ // type args into a common type.
3390
+ if (!(0, types_1.isTypeVarTuple)(typeVar) &&
3391
+ (0, types_1.isClassInstance)(replacement) &&
3392
+ replacement.priv.tupleTypeArgs &&
3393
+ replacement.priv.isUnpacked) {
3394
+ replacement = combineTupleTypeArgs(replacement.priv.tupleTypeArgs);
3395
+ }
3403
3396
  if (!(0, types_1.isTypeVar)(replacement) ||
3404
3397
  !replacement.priv.isInScopePlaceholder ||
3405
3398
  !this._options.unknownIfNotFound) {
@@ -3425,16 +3418,16 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
3425
3418
  if (typeVar.shared.isDefaultExplicit && !this._options.useUnknownOverDefault) {
3426
3419
  return this._solveDefaultType(typeVar, recursionCount);
3427
3420
  }
3428
- return getUnknownTypeForTypeVar(typeVar, this._options.tupleClassType);
3421
+ return getUnknownForTypeVar(typeVar, this._options.tupleClassType);
3429
3422
  }
3430
3423
  }
3431
3424
  // If we're solving a default type, handle type variables with no scope ID.
3432
3425
  if (this._isSolvingDefaultType && !typeVar.priv.scopeId) {
3433
- const replacementEntry = signatureContext
3426
+ const replacementEntry = solutionSet
3434
3427
  .getTypeVars()
3435
3428
  .find((entry) => entry.typeVar.shared.name === typeVar.shared.name);
3436
3429
  if (replacementEntry) {
3437
- return signatureContext.getTypeVarType(replacementEntry.typeVar);
3430
+ return solutionSet.getTypeVarType(replacementEntry.typeVar);
3438
3431
  }
3439
3432
  if (typeVar.shared.isDefaultExplicit) {
3440
3433
  return this.apply(typeVar.shared.defaultType, recursionCount);
@@ -3454,8 +3447,8 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
3454
3447
  if ((0, types_1.isTypeVar)(preTransform) &&
3455
3448
  preTransform.priv.scopeId !== undefined &&
3456
3449
  this._typeVarContext.hasSolveForScope(preTransform.priv.scopeId)) {
3457
- const signatureContext = this._typeVarContext.getSignatureContext((_a = this._activeTypeVarSignatureContextIndex) !== null && _a !== void 0 ? _a : 0);
3458
- const typeVarType = signatureContext.getTypeVarType(preTransform);
3450
+ const solutionSet = this._typeVarContext.getSolutionSet((_a = this._activeSolutionSetIndex) !== null && _a !== void 0 ? _a : 0);
3451
+ const typeVarType = solutionSet.getTypeVarType(preTransform);
3459
3452
  // Did the TypeVar remain unsolved?
3460
3453
  if (!typeVarType || ((0, types_1.isTypeVar)(typeVarType) && typeVarType.priv.isInScopePlaceholder)) {
3461
3454
  // If the TypeVar was not transformed, then it was unsolved,
@@ -3477,36 +3470,38 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
3477
3470
  var _a;
3478
3471
  if (!typeVar.priv.scopeId || !this._typeVarContext.hasSolveForScope(typeVar.priv.scopeId)) {
3479
3472
  const defaultType = typeVar.shared.defaultType;
3480
- if (typeVar.shared.isDefaultExplicit &&
3481
- (0, types_1.isClassInstance)(defaultType) &&
3482
- defaultType.priv.tupleTypeArguments) {
3483
- return defaultType.priv.tupleTypeArguments;
3473
+ if (typeVar.shared.isDefaultExplicit && (0, types_1.isClassInstance)(defaultType) && defaultType.priv.tupleTypeArgs) {
3474
+ return defaultType.priv.tupleTypeArgs;
3484
3475
  }
3485
3476
  return undefined;
3486
3477
  }
3487
- const signatureContext = this._typeVarContext.getSignatureContext((_a = this._activeTypeVarSignatureContextIndex) !== null && _a !== void 0 ? _a : 0);
3488
- return signatureContext.getTupleTypeVar(typeVar);
3478
+ const solutionSet = this._typeVarContext.getSolutionSet((_a = this._activeSolutionSetIndex) !== null && _a !== void 0 ? _a : 0);
3479
+ const value = solutionSet.getTypeVarType(typeVar);
3480
+ if (value && (0, types_1.isClassInstance)(value) && value.priv.tupleTypeArgs && (0, types_1.isUnpackedClass)(value)) {
3481
+ return value.priv.tupleTypeArgs;
3482
+ }
3483
+ return undefined;
3489
3484
  }
3490
3485
  transformParamSpec(paramSpec, recursionCount) {
3491
3486
  var _a, _b;
3492
- const signatureContext = this._typeVarContext.getSignatureContext((_a = this._activeTypeVarSignatureContextIndex) !== null && _a !== void 0 ? _a : 0);
3487
+ const solutionSet = this._typeVarContext.getSolutionSet((_a = this._activeSolutionSetIndex) !== null && _a !== void 0 ? _a : 0);
3493
3488
  // If we're solving a default type, handle param specs with no scope ID.
3494
3489
  if (this._isSolvingDefaultType && !paramSpec.priv.scopeId) {
3495
- const replacementEntry = signatureContext
3490
+ const replacementEntry = solutionSet
3496
3491
  .getTypeVars()
3497
3492
  .find((entry) => entry.typeVar.shared.name === paramSpec.shared.name);
3498
- if (replacementEntry) {
3499
- return signatureContext.getParamSpecType(replacementEntry.typeVar);
3493
+ if (replacementEntry && (0, types_1.isParamSpec)(replacementEntry.typeVar)) {
3494
+ return solutionSet.getTypeVarType(replacementEntry.typeVar);
3500
3495
  }
3501
3496
  if (paramSpec.shared.isDefaultExplicit) {
3502
3497
  return convertTypeToParamSpecValue(this.apply(paramSpec.shared.defaultType, recursionCount));
3503
3498
  }
3504
- return getUnknownTypeForParamSpec();
3499
+ return types_1.ParamSpecType.getUnknown();
3505
3500
  }
3506
3501
  if (!paramSpec.priv.scopeId || !this._typeVarContext.hasSolveForScope(paramSpec.priv.scopeId)) {
3507
3502
  return undefined;
3508
3503
  }
3509
- const transformedParamSpec = signatureContext.getParamSpecType(paramSpec);
3504
+ const transformedParamSpec = solutionSet.getTypeVarType(paramSpec);
3510
3505
  if (transformedParamSpec) {
3511
3506
  return transformedParamSpec;
3512
3507
  }
@@ -3526,7 +3521,7 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
3526
3521
  return convertTypeToParamSpecValue(this._solveDefaultType(paramSpec, recursionCount));
3527
3522
  }
3528
3523
  // Convert to the ParamSpec equivalent of "Unknown".
3529
- return getUnknownTypeForParamSpec();
3524
+ return types_1.ParamSpecType.getUnknown();
3530
3525
  }
3531
3526
  return undefined;
3532
3527
  }
@@ -3535,18 +3530,18 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
3535
3530
  if (!((_a = type.props) === null || _a === void 0 ? void 0 : _a.condition)) {
3536
3531
  return type;
3537
3532
  }
3538
- const signatureContext = this._typeVarContext.getSignatureContext((_b = this._activeTypeVarSignatureContextIndex) !== null && _b !== void 0 ? _b : 0);
3533
+ const solutionSet = this._typeVarContext.getSolutionSet((_b = this._activeSolutionSetIndex) !== null && _b !== void 0 ? _b : 0);
3539
3534
  for (const condition of type.props.condition) {
3540
3535
  // This doesn't apply to bound type variables.
3541
3536
  if (condition.typeVar.shared.constraints.length === 0) {
3542
3537
  continue;
3543
3538
  }
3544
3539
  const conditionTypeVar = (_d = (_c = condition.typeVar.priv) === null || _c === void 0 ? void 0 : _c.externalTypeVar) !== null && _d !== void 0 ? _d : condition.typeVar;
3545
- const typeVarEntry = signatureContext.getTypeVar(conditionTypeVar);
3540
+ const typeVarEntry = solutionSet.getTypeVar(conditionTypeVar);
3546
3541
  if (!typeVarEntry || condition.constraintIndex >= typeVarEntry.typeVar.shared.constraints.length) {
3547
3542
  continue;
3548
3543
  }
3549
- const value = signatureContext.getTypeVarType(typeVarEntry.typeVar);
3544
+ const value = solutionSet.getTypeVarType(typeVarEntry.typeVar);
3550
3545
  if (!value) {
3551
3546
  continue;
3552
3547
  }
@@ -3558,19 +3553,19 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
3558
3553
  }
3559
3554
  return type;
3560
3555
  }
3561
- doForEachSignatureContext(callback) {
3562
- const signatureContexts = this._typeVarContext.getSignatureContexts();
3556
+ doForEachSolutionSet(callback) {
3557
+ const solutionSet = this._typeVarContext.getSolutionSets();
3563
3558
  // Handle the common case where there are not multiple signature contexts.
3564
- if (signatureContexts.length <= 1) {
3559
+ if (solutionSet.length <= 1) {
3565
3560
  return callback();
3566
3561
  }
3567
3562
  // Loop through all of the signature contexts in the type var context
3568
3563
  // to create an overload type.
3569
- const overloadTypes = signatureContexts.map((_, index) => {
3570
- this._activeTypeVarSignatureContextIndex = index;
3564
+ const overloadTypes = solutionSet.map((_, index) => {
3565
+ this._activeSolutionSetIndex = index;
3571
3566
  return callback();
3572
3567
  });
3573
- this._activeTypeVarSignatureContextIndex = undefined;
3568
+ this._activeSolutionSetIndex = undefined;
3574
3569
  const filteredOverloads = [];
3575
3570
  doForEachSubtype((0, types_1.combineTypes)(overloadTypes), (subtype) => {
3576
3571
  (0, debug_1.assert)((0, types_1.isFunction)(subtype));
@@ -3614,31 +3609,31 @@ class ExpectedTypeTransformer extends TypeVarTransformer {
3614
3609
  }
3615
3610
  }
3616
3611
  class InScopePlaceholderTransformer extends TypeVarTransformer {
3617
- constructor(_signatureContext) {
3612
+ constructor(_solutionSet) {
3618
3613
  super();
3619
- this._signatureContext = _signatureContext;
3614
+ this._solutionSet = _solutionSet;
3620
3615
  }
3621
3616
  transformTypeVar(typeVar) {
3622
3617
  var _a;
3623
3618
  if (typeVar.priv.isInScopePlaceholder) {
3624
- return (_a = this._signatureContext.getTypeVarType(typeVar)) !== null && _a !== void 0 ? _a : typeVar;
3619
+ return (_a = this._solutionSet.getTypeVarType(typeVar)) !== null && _a !== void 0 ? _a : typeVar;
3625
3620
  }
3626
3621
  return undefined;
3627
3622
  }
3628
3623
  transformParamSpec(paramSpec) {
3629
3624
  if (paramSpec.priv.isInScopePlaceholder) {
3630
- return this._signatureContext.getParamSpecType(paramSpec);
3625
+ return this._solutionSet.getTypeVarType(paramSpec);
3631
3626
  }
3632
3627
  return undefined;
3633
3628
  }
3634
3629
  }
3635
- function applyInScopePlaceholdersToType(type, signatureContext) {
3630
+ function applyInScopePlaceholdersToType(type, solutionSet) {
3636
3631
  // Handle the common case where there are no in-scope placeholders.
3637
3632
  // No more work is required in this case.
3638
- if (!signatureContext.getTypeVars().some((entry) => entry.typeVar.priv.isInScopePlaceholder)) {
3633
+ if (!solutionSet.getTypeVars().some((entry) => entry.typeVar.priv.isInScopePlaceholder)) {
3639
3634
  return type;
3640
3635
  }
3641
- const transformer = new InScopePlaceholderTransformer(signatureContext);
3636
+ const transformer = new InScopePlaceholderTransformer(solutionSet);
3642
3637
  return transformer.apply(type, 0);
3643
3638
  }
3644
3639
  //# sourceMappingURL=typeUtils.js.map