@zzzen/pyright-internal 1.2.0-dev.20240714 → 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 (225) 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 +137 -142
  9. package/dist/analyzer/checker.js.map +1 -1
  10. package/dist/analyzer/codeFlowEngine.d.ts +2 -2
  11. package/dist/analyzer/codeFlowEngine.js +74 -44
  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 +166 -206
  17. package/dist/analyzer/constraintSolver.js.map +1 -1
  18. package/dist/analyzer/constructorTransform.d.ts +2 -3
  19. package/dist/analyzer/constructorTransform.js +18 -19
  20. package/dist/analyzer/constructorTransform.js.map +1 -1
  21. package/dist/analyzer/constructors.d.ts +3 -3
  22. package/dist/analyzer/constructors.js +72 -175
  23. package/dist/analyzer/constructors.js.map +1 -1
  24. package/dist/analyzer/dataClasses.d.ts +2 -2
  25. package/dist/analyzer/dataClasses.js +60 -40
  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 +5 -6
  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 +145 -96
  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 +60 -59
  54. package/dist/analyzer/parameterUtils.js.map +1 -1
  55. package/dist/analyzer/parseTreeUtils.d.ts +7 -6
  56. package/dist/analyzer/parseTreeUtils.js +47 -24
  57. package/dist/analyzer/parseTreeUtils.js.map +1 -1
  58. package/dist/analyzer/patternMatching.js +109 -90
  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 +23 -19
  63. package/dist/analyzer/properties.js.map +1 -1
  64. package/dist/analyzer/protocols.js +23 -20
  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/testWalker.js +13 -1
  82. package/dist/analyzer/testWalker.js.map +1 -1
  83. package/dist/analyzer/tracePrinter.js +4 -4
  84. package/dist/analyzer/tracePrinter.js.map +1 -1
  85. package/dist/analyzer/tuples.d.ts +9 -0
  86. package/dist/analyzer/tuples.js +252 -0
  87. package/dist/analyzer/tuples.js.map +1 -0
  88. package/dist/analyzer/typeComplexity.d.ts +2 -0
  89. package/dist/analyzer/typeComplexity.js +86 -0
  90. package/dist/analyzer/typeComplexity.js.map +1 -0
  91. package/dist/analyzer/typeEvaluator.js +1721 -1824
  92. package/dist/analyzer/typeEvaluator.js.map +1 -1
  93. package/dist/analyzer/typeEvaluatorTypes.d.ts +47 -40
  94. package/dist/analyzer/typeEvaluatorTypes.js +10 -1
  95. package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
  96. package/dist/analyzer/typeGuards.js +116 -90
  97. package/dist/analyzer/typeGuards.js.map +1 -1
  98. package/dist/analyzer/typePrinter.d.ts +1 -1
  99. package/dist/analyzer/typePrinter.js +54 -53
  100. package/dist/analyzer/typePrinter.js.map +1 -1
  101. package/dist/analyzer/typeStubWriter.d.ts +3 -3
  102. package/dist/analyzer/typeStubWriter.js +15 -15
  103. package/dist/analyzer/typeStubWriter.js.map +1 -1
  104. package/dist/analyzer/typeUtils.d.ts +35 -29
  105. package/dist/analyzer/typeUtils.js +420 -357
  106. package/dist/analyzer/typeUtils.js.map +1 -1
  107. package/dist/analyzer/typeVarContext.d.ts +24 -36
  108. package/dist/analyzer/typeVarContext.js +89 -193
  109. package/dist/analyzer/typeVarContext.js.map +1 -1
  110. package/dist/analyzer/typeWalker.js +4 -4
  111. package/dist/analyzer/typeWalker.js.map +1 -1
  112. package/dist/analyzer/typedDicts.d.ts +2 -2
  113. package/dist/analyzer/typedDicts.js +49 -53
  114. package/dist/analyzer/typedDicts.js.map +1 -1
  115. package/dist/analyzer/types.d.ts +89 -63
  116. package/dist/analyzer/types.js +163 -120
  117. package/dist/analyzer/types.js.map +1 -1
  118. package/dist/commands/dumpFileDebugInfoCommand.js +12 -12
  119. package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
  120. package/dist/common/configOptions.d.ts +1 -0
  121. package/dist/common/configOptions.js +5 -0
  122. package/dist/common/configOptions.js.map +1 -1
  123. package/dist/common/diagnosticRules.d.ts +1 -0
  124. package/dist/common/diagnosticRules.js +1 -0
  125. package/dist/common/diagnosticRules.js.map +1 -1
  126. package/dist/common/fileSystem.d.ts +0 -1
  127. package/dist/common/fileSystem.js.map +1 -1
  128. package/dist/common/languageServerInterface.d.ts +13 -0
  129. package/dist/common/languageServerInterface.js +15 -1
  130. package/dist/common/languageServerInterface.js.map +1 -1
  131. package/dist/common/lspUtils.js +2 -2
  132. package/dist/common/memUtils.d.ts +4 -0
  133. package/dist/common/memUtils.js +33 -2
  134. package/dist/common/memUtils.js.map +1 -1
  135. package/dist/common/serviceKeys.d.ts +3 -0
  136. package/dist/common/serviceKeys.js +2 -0
  137. package/dist/common/serviceKeys.js.map +1 -1
  138. package/dist/common/serviceProviderExtensions.js +7 -0
  139. package/dist/common/serviceProviderExtensions.js.map +1 -1
  140. package/dist/languageServerBase.d.ts +4 -3
  141. package/dist/languageServerBase.js +14 -10
  142. package/dist/languageServerBase.js.map +1 -1
  143. package/dist/languageService/autoImporter.d.ts +3 -2
  144. package/dist/languageService/autoImporter.js +5 -1
  145. package/dist/languageService/autoImporter.js.map +1 -1
  146. package/dist/languageService/completionProvider.d.ts +5 -3
  147. package/dist/languageService/completionProvider.js +38 -37
  148. package/dist/languageService/completionProvider.js.map +1 -1
  149. package/dist/languageService/completionProviderUtils.d.ts +1 -1
  150. package/dist/languageService/completionProviderUtils.js +3 -3
  151. package/dist/languageService/completionProviderUtils.js.map +1 -1
  152. package/dist/languageService/fileWatcherDynamicFeature.js +2 -2
  153. package/dist/languageService/fileWatcherDynamicFeature.js.map +1 -1
  154. package/dist/languageService/hoverProvider.js +14 -6
  155. package/dist/languageService/hoverProvider.js.map +1 -1
  156. package/dist/languageService/referencesProvider.d.ts +10 -4
  157. package/dist/languageService/referencesProvider.js +24 -12
  158. package/dist/languageService/referencesProvider.js.map +1 -1
  159. package/dist/languageService/renameProvider.js +21 -4
  160. package/dist/languageService/renameProvider.js.map +1 -1
  161. package/dist/languageService/signatureHelpProvider.js +1 -1
  162. package/dist/languageService/signatureHelpProvider.js.map +1 -1
  163. package/dist/languageService/tooltipUtils.js +3 -3
  164. package/dist/languageService/tooltipUtils.js.map +1 -1
  165. package/dist/localization/localize.d.ts +9 -3
  166. package/dist/localization/localize.js +8 -1
  167. package/dist/localization/localize.js.map +1 -1
  168. package/dist/localization/package.nls.cs.json +5 -2
  169. package/dist/localization/package.nls.de.json +5 -2
  170. package/dist/localization/package.nls.en-us.json +7 -1
  171. package/dist/localization/package.nls.es.json +5 -2
  172. package/dist/localization/package.nls.fr.json +5 -2
  173. package/dist/localization/package.nls.it.json +5 -2
  174. package/dist/localization/package.nls.ja.json +5 -2
  175. package/dist/localization/package.nls.ko.json +5 -2
  176. package/dist/localization/package.nls.pl.json +5 -2
  177. package/dist/localization/package.nls.pt-br.json +5 -2
  178. package/dist/localization/package.nls.qps-ploc.json +5 -2
  179. package/dist/localization/package.nls.ru.json +5 -2
  180. package/dist/localization/package.nls.tr.json +5 -2
  181. package/dist/localization/package.nls.zh-cn.json +5 -2
  182. package/dist/localization/package.nls.zh-tw.json +5 -2
  183. package/dist/parser/parseNodes.d.ts +12 -10
  184. package/dist/parser/parseNodes.js +23 -21
  185. package/dist/parser/parseNodes.js.map +1 -1
  186. package/dist/parser/parser.js +66 -43
  187. package/dist/parser/parser.js.map +1 -1
  188. package/dist/tests/checker.test.js +2 -2
  189. package/dist/tests/fourslash/rename.args.fourslash.d.ts +1 -0
  190. package/dist/tests/fourslash/rename.args.fourslash.js +71 -0
  191. package/dist/tests/fourslash/rename.args.fourslash.js.map +1 -0
  192. package/dist/tests/fourslash/signature.builtinDocstrings.fourslash.js +4 -21
  193. package/dist/tests/fourslash/signature.builtinDocstrings.fourslash.js.map +1 -1
  194. package/dist/tests/fourslash/signature.complicated.fourslash.js +1 -1
  195. package/dist/tests/fourslash/signature.complicated.fourslash.js.map +1 -1
  196. package/dist/tests/harness/fourslash/fourSlashParser.js +1 -1
  197. package/dist/tests/harness/fourslash/fourSlashParser.js.map +1 -1
  198. package/dist/tests/harness/fourslash/testStateUtils.js +2 -2
  199. package/dist/tests/harness/fourslash/testStateUtils.js.map +1 -1
  200. package/dist/tests/harness/vfs/filesystem.d.ts +0 -1
  201. package/dist/tests/harness/vfs/filesystem.js +0 -4
  202. package/dist/tests/harness/vfs/filesystem.js.map +1 -1
  203. package/dist/tests/importResolver.test.js +62 -15
  204. package/dist/tests/importResolver.test.js.map +1 -1
  205. package/dist/tests/lsp/languageServerTestUtils.js +1 -1
  206. package/dist/tests/lsp/languageServerTestUtils.js.map +1 -1
  207. package/dist/tests/typeEvaluator1.test.js +17 -0
  208. package/dist/tests/typeEvaluator1.test.js.map +1 -1
  209. package/dist/tests/typeEvaluator2.test.js +4 -0
  210. package/dist/tests/typeEvaluator2.test.js.map +1 -1
  211. package/dist/tests/typeEvaluator3.test.js +1 -1
  212. package/dist/tests/typeEvaluator4.test.js +19 -7
  213. package/dist/tests/typeEvaluator4.test.js.map +1 -1
  214. package/dist/tests/typeEvaluator5.test.js +8 -2
  215. package/dist/tests/typeEvaluator5.test.js.map +1 -1
  216. package/dist/tests/typeEvaluator6.test.js +76 -60
  217. package/dist/tests/typeEvaluator6.test.js.map +1 -1
  218. package/dist/tests/typeEvaluator7.test.js +5 -1
  219. package/dist/tests/typeEvaluator7.test.js.map +1 -1
  220. package/dist/tests/typePrinter.test.js +13 -18
  221. package/dist/tests/typePrinter.test.js.map +1 -1
  222. package/dist/workspaceFactory.d.ts +3 -2
  223. package/dist/workspaceFactory.js +15 -2
  224. package/dist/workspaceFactory.js.map +1 -1
  225. package/package.json +1 -1
@@ -8,8 +8,8 @@
8
8
  * Representation of types used during type analysis within Python.
9
9
  */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.findSubtype = exports.removeFromUnion = exports.removeUnbound = exports.removeUnknownFromUnion = exports.isTypeSame = exports.getTypeAliasInfo = exports.isOverloadedFunction = exports.isFunction = exports.isParamSpec = exports.isUnpacked = exports.isUnpackedClass = exports.isUnpackedVariadicTypeVar = exports.isVariadicTypeVar = exports.isTypeVar = exports.isModule = exports.isClassInstance = exports.isInstantiableClass = exports.isClass = exports.isPossiblyUnbound = exports.isUnion = exports.isUnbound = exports.isAnyOrUnknown = exports.isUnknown = exports.isAny = exports.isNever = exports.TypeVarType = exports.TypeVarScopeType = exports.Variance = exports.UnionType = exports.TypeCondition = exports.AnyType = exports.NeverType = exports.OverloadedFunctionType = exports.FunctionType = exports.FunctionTypeFlags = exports.isKeywordOnlySeparator = exports.isPositionOnlySeparator = exports.FunctionParam = exports.FunctionParamFlags = exports.ClassType = exports.ClassTypeFlags = exports.ModuleType = exports.UnknownType = exports.UnboundType = exports.TypeBase = exports.maxTypeRecursionCount = exports.EnumLiteral = exports.InScopePlaceholderScopeId = exports.TypeFlags = exports.TypeCategory = void 0;
12
- exports.isSameWithoutLiteralValue = exports.combineTypes = void 0;
11
+ exports.removeUnbound = exports.removeUnknownFromUnion = exports.isTypeSame = exports.getTypeAliasInfo = exports.isOverloadedFunction = exports.isFunction = exports.isUnpacked = exports.isUnpackedClass = exports.isUnpackedTypeVarTuple = exports.isTypeVarTuple = exports.isParamSpec = exports.isTypeVar = exports.isModule = exports.isClassInstance = exports.isInstantiableClass = exports.isClass = exports.isPossiblyUnbound = exports.isUnion = exports.isUnbound = exports.isAnyOrUnknown = exports.isUnknown = exports.isAny = exports.isNever = exports.TypeVarType = exports.ParamSpecType = exports.TypeVarScopeType = exports.TypeVarKind = exports.Variance = exports.UnionType = exports.TypeCondition = exports.AnyType = exports.NeverType = exports.OverloadedFunctionType = exports.FunctionType = exports.FunctionTypeFlags = exports.isKeywordOnlySeparator = exports.isPositionOnlySeparator = exports.FunctionParam = exports.FunctionParamFlags = exports.ClassType = exports.ClassTypeFlags = exports.ModuleType = exports.UnknownType = exports.UnboundType = exports.TypeBase = exports.maxTypeRecursionCount = exports.EnumLiteral = exports.InScopePlaceholderScopeId = exports.TypeFlags = exports.TypeCategory = void 0;
12
+ exports.isSameWithoutLiteralValue = exports.combineTypes = exports.findSubtype = exports.removeFromUnion = void 0;
13
13
  const debug_1 = require("../common/debug");
14
14
  var TypeCategory;
15
15
  (function (TypeCategory) {
@@ -195,9 +195,9 @@ var TypeBase;
195
195
  fileUri,
196
196
  typeVarScopeId,
197
197
  isPep695Syntax,
198
- typeParameters: typeParams,
198
+ typeParams: typeParams,
199
199
  usageVariance: undefined,
200
- typeArguments: typeArgs,
200
+ typeArgs: typeArgs,
201
201
  });
202
202
  return typeClone;
203
203
  }
@@ -442,7 +442,7 @@ var ClassType;
442
442
  effectiveMetaclass,
443
443
  mro: [],
444
444
  fields: new Map(),
445
- typeParameters: [],
445
+ typeParams: [],
446
446
  docString,
447
447
  },
448
448
  priv: {},
@@ -480,20 +480,25 @@ var ClassType;
480
480
  return newInstance;
481
481
  }
482
482
  ClassType.cloneAsInstantiable = cloneAsInstantiable;
483
- function cloneForSpecialization(classType, typeArguments, isTypeArgumentExplicit, includeSubclasses = false, tupleTypeArguments, isEmptyContainer) {
483
+ function specialize(classType, typeArgs, isTypeArgExplicit, includeSubclasses = false, tupleTypeArgs, isEmptyContainer) {
484
484
  const newClassType = TypeBase.cloneType(classType);
485
- newClassType.priv.typeArguments = (typeArguments === null || typeArguments === void 0 ? void 0 : typeArguments.length) === 0 ? undefined : typeArguments;
486
- newClassType.priv.isTypeArgumentExplicit = isTypeArgumentExplicit;
485
+ newClassType.priv.typeArgs = (typeArgs === null || typeArgs === void 0 ? void 0 : typeArgs.length) === 0 ? undefined : typeArgs;
486
+ // If the user passed undefined for this argument, infer it
487
+ // based on whether typeArgs was provided.
488
+ if (isTypeArgExplicit === undefined) {
489
+ isTypeArgExplicit = !!typeArgs;
490
+ }
491
+ newClassType.priv.isTypeArgExplicit = isTypeArgExplicit;
487
492
  if (includeSubclasses) {
488
493
  newClassType.priv.includeSubclasses = true;
489
494
  }
490
- newClassType.priv.tupleTypeArguments = tupleTypeArguments ? [...tupleTypeArguments] : undefined;
495
+ newClassType.priv.tupleTypeArgs = tupleTypeArgs ? [...tupleTypeArgs] : undefined;
491
496
  if (isEmptyContainer !== undefined) {
492
497
  newClassType.priv.isEmptyContainer = isEmptyContainer;
493
498
  }
494
499
  return newClassType;
495
500
  }
496
- ClassType.cloneForSpecialization = cloneForSpecialization;
501
+ ClassType.specialize = specialize;
497
502
  function cloneIncludeSubclasses(classType, includeSubclasses = true) {
498
503
  if (!!classType.priv.includeSubclasses === includeSubclasses) {
499
504
  return classType;
@@ -550,13 +555,6 @@ var ClassType;
550
555
  return newClassType;
551
556
  }
552
557
  ClassType.cloneRemoveTypePromotions = cloneRemoveTypePromotions;
553
- function cloneForTypeGuard(classType, typeGuardType, isStrictTypeGuard) {
554
- const newClassType = TypeBase.cloneType(classType);
555
- newClassType.priv.typeGuardType = typeGuardType;
556
- newClassType.priv.isStrictTypeGuard = isStrictTypeGuard;
557
- return newClassType;
558
- }
559
- ClassType.cloneForTypeGuard = cloneForTypeGuard;
560
558
  function cloneForSymbolTableUpdate(classType) {
561
559
  const newClassType = TypeBase.cloneType(classType);
562
560
  newClassType.shared = { ...newClassType.shared };
@@ -651,7 +649,7 @@ var ClassType;
651
649
  ClassType.isTypedDictNarrower = isTypedDictNarrower;
652
650
  // Is the class generic but not specialized?
653
651
  function isUnspecialized(classType) {
654
- return classType.shared.typeParameters.length > 0 && classType.priv.typeArguments === undefined;
652
+ return classType.shared.typeParams.length > 0 && classType.priv.typeArgs === undefined;
655
653
  }
656
654
  ClassType.isUnspecialized = isUnspecialized;
657
655
  function isSpecialBuiltIn(classType, className) {
@@ -813,10 +811,10 @@ var ClassType;
813
811
  return !!(classType.shared.flags & 524288 /* ClassTypeFlags.ReadOnlyInstanceVariables */);
814
812
  }
815
813
  ClassType.isReadOnlyInstanceVariables = isReadOnlyInstanceVariables;
816
- function getTypeParameters(classType) {
817
- return classType.shared.typeParameters;
814
+ function getTypeParams(classType) {
815
+ return classType.shared.typeParams;
818
816
  }
819
- ClassType.getTypeParameters = getTypeParameters;
817
+ ClassType.getTypeParams = getTypeParams;
820
818
  function derivesFromAnyOrUnknown(classType) {
821
819
  return classType.shared.mro.some((baseClass) => isAnyOrUnknown(baseClass));
822
820
  }
@@ -860,7 +858,7 @@ var ClassType;
860
858
  class1Details.flags !== class2Details.flags ||
861
859
  class1Details.typeSourceId !== class2Details.typeSourceId ||
862
860
  class1Details.baseClasses.length !== class2Details.baseClasses.length ||
863
- class1Details.typeParameters.length !== class2Details.typeParameters.length) {
861
+ class1Details.typeParams.length !== class2Details.typeParams.length) {
864
862
  return false;
865
863
  }
866
864
  if (recursionCount > exports.maxTypeRecursionCount) {
@@ -888,8 +886,8 @@ var ClassType;
888
886
  return false;
889
887
  }
890
888
  }
891
- for (let i = 0; i < class1Details.typeParameters.length; i++) {
892
- if (!isTypeSame(class1Details.typeParameters[i], class2Details.typeParameters[i], { ignorePseudoGeneric: true }, recursionCount)) {
889
+ for (let i = 0; i < class1Details.typeParams.length; i++) {
890
+ if (!isTypeSame(class1Details.typeParams[i], class2Details.typeParams[i], { ignorePseudoGeneric: true }, recursionCount)) {
893
891
  return false;
894
892
  }
895
893
  }
@@ -989,12 +987,12 @@ var FunctionParam;
989
987
  })(FunctionParam || (exports.FunctionParam = FunctionParam = {}));
990
988
  function isPositionOnlySeparator(param) {
991
989
  // A simple parameter with no name is treated as a "/" separator.
992
- return param.category === 0 /* ParameterCategory.Simple */ && !param.name;
990
+ return param.category === 0 /* ParamCategory.Simple */ && !param.name;
993
991
  }
994
992
  exports.isPositionOnlySeparator = isPositionOnlySeparator;
995
993
  function isKeywordOnlySeparator(param) {
996
994
  // An *args parameter with no name is treated as a "*" separator.
997
- return param.category === 1 /* ParameterCategory.ArgsList */ && !param.name;
995
+ return param.category === 1 /* ParamCategory.ArgsList */ && !param.name;
998
996
  }
999
997
  exports.isKeywordOnlySeparator = isKeywordOnlySeparator;
1000
998
  var FunctionTypeFlags;
@@ -1078,7 +1076,7 @@ var FunctionType;
1078
1076
  fullName,
1079
1077
  moduleName,
1080
1078
  flags: functionFlags,
1081
- typeParameters: [],
1079
+ typeParams: [],
1082
1080
  parameters: [],
1083
1081
  declaredReturnType: undefined,
1084
1082
  declaration: undefined,
@@ -1105,11 +1103,11 @@ var FunctionType;
1105
1103
  }
1106
1104
  if (stripFirstParam) {
1107
1105
  if (type.shared.parameters.length > 0) {
1108
- if (type.shared.parameters[0].category === 0 /* ParameterCategory.Simple */) {
1106
+ if (type.shared.parameters[0].category === 0 /* ParamCategory.Simple */) {
1109
1107
  if (type.shared.parameters.length > 0 && !FunctionParam.isTypeInferred(type.shared.parameters[0])) {
1110
1108
  // Stash away the effective type of the first parameter if it
1111
1109
  // wasn't synthesized.
1112
- newFunction.priv.strippedFirstParamType = getEffectiveParameterType(type, 0);
1110
+ newFunction.priv.strippedFirstParamType = getEffectiveParamType(type, 0);
1113
1111
  }
1114
1112
  newFunction.shared.parameters = type.shared.parameters.slice(1);
1115
1113
  }
@@ -1164,7 +1162,7 @@ var FunctionType;
1164
1162
  // Creates a shallow copy of the function type with new
1165
1163
  // specialized types. The clone shares the _functionDetails
1166
1164
  // with the object being cloned.
1167
- function cloneForSpecialization(type, specializedTypes, specializedInferredReturnType) {
1165
+ function specialize(type, specializedTypes, specializedInferredReturnType) {
1168
1166
  const newFunction = TypeBase.cloneType(type);
1169
1167
  (0, debug_1.assert)(specializedTypes.parameterTypes.length === type.shared.parameters.length);
1170
1168
  if (specializedTypes.parameterDefaultArgs) {
@@ -1174,7 +1172,7 @@ var FunctionType;
1174
1172
  newFunction.priv.inferredReturnType = specializedInferredReturnType;
1175
1173
  return newFunction;
1176
1174
  }
1177
- FunctionType.cloneForSpecialization = cloneForSpecialization;
1175
+ FunctionType.specialize = specialize;
1178
1176
  // Creates a new function based on the parameters of another function.
1179
1177
  function applyParamSpecValue(type, paramSpecValue) {
1180
1178
  const hasPositionalOnly = paramSpecValue.shared.parameters.some((param) => isPositionOnlySeparator(param));
@@ -1183,7 +1181,7 @@ var FunctionType;
1183
1181
  (0, debug_1.assert)(paramSpec !== undefined);
1184
1182
  // Make a shallow clone of the details.
1185
1183
  newFunction.shared = { ...newFunction.shared };
1186
- newFunction.shared.typeParameters = newFunction.shared.typeParameters.filter((t) => !isTypeSame(t, paramSpec));
1184
+ newFunction.shared.typeParams = newFunction.shared.typeParams.filter((t) => !isTypeSame(t, paramSpec));
1187
1185
  const prevParams = Array.from(newFunction.shared.parameters);
1188
1186
  newFunction.shared.parameters = [
1189
1187
  ...prevParams,
@@ -1243,15 +1241,14 @@ var FunctionType;
1243
1241
  return newFunction;
1244
1242
  }
1245
1243
  FunctionType.cloneWithNewFlags = cloneWithNewFlags;
1246
- function cloneWithNewTypeVarScopeId(type, newScopeId, newConstructorScopeId, typeParameters, trackedSignatures) {
1244
+ function cloneWithNewTypeVarScopeId(type, newScopeId, newConstructorScopeId, typeParams) {
1247
1245
  const newFunction = TypeBase.cloneType(type);
1248
1246
  // Make a shallow clone of the details.
1249
1247
  newFunction.shared = { ...type.shared };
1250
1248
  newFunction.shared.typeVarScopeId = newScopeId;
1251
1249
  newFunction.priv.constructorTypeVarScopeId = newConstructorScopeId;
1252
- newFunction.shared.typeParameters = typeParameters;
1253
- newFunction.priv.trackedSignatures = trackedSignatures;
1254
- FunctionType.addHigherOrderTypeVarScopeIds(newFunction, typeParameters.map((t) => t.priv.scopeId));
1250
+ newFunction.shared.typeParams = typeParams;
1251
+ FunctionType.addHigherOrderTypeVarScopeIds(newFunction, typeParams.map((t) => { var _a, _b; return (_b = (_a = t.priv.externalTypeVar) === null || _a === void 0 ? void 0 : _a.priv.scopeId) !== null && _b !== void 0 ? _b : t.priv.scopeId; }));
1255
1252
  return newFunction;
1256
1253
  }
1257
1254
  FunctionType.cloneWithNewTypeVarScopeId = cloneWithNewTypeVarScopeId;
@@ -1282,12 +1279,11 @@ var FunctionType;
1282
1279
  }
1283
1280
  const argsParam = type.shared.parameters[paramCount - 2];
1284
1281
  const kwargsParam = type.shared.parameters[paramCount - 1];
1285
- if (argsParam.category !== 1 /* ParameterCategory.ArgsList */ ||
1286
- kwargsParam.category !== 2 /* ParameterCategory.KwargsDict */) {
1282
+ if (argsParam.category !== 1 /* ParamCategory.ArgsList */ || kwargsParam.category !== 2 /* ParamCategory.KwargsDict */) {
1287
1283
  return type;
1288
1284
  }
1289
- const argsType = FunctionType.getEffectiveParameterType(type, paramCount - 2);
1290
- const kwargsType = FunctionType.getEffectiveParameterType(type, paramCount - 1);
1285
+ const argsType = FunctionType.getEffectiveParamType(type, paramCount - 2);
1286
+ const kwargsType = FunctionType.getEffectiveParamType(type, paramCount - 1);
1291
1287
  if (!isParamSpec(argsType) || !isParamSpec(kwargsType) || !isTypeSame(argsType, kwargsType)) {
1292
1288
  return type;
1293
1289
  }
@@ -1328,11 +1324,11 @@ var FunctionType;
1328
1324
  }
1329
1325
  const secondLastParam = params[params.length - 2];
1330
1326
  const lastParam = params[params.length - 1];
1331
- if (secondLastParam.category === 1 /* ParameterCategory.ArgsList */ &&
1332
- isTypeVar(secondLastParam.type) &&
1327
+ if (secondLastParam.category === 1 /* ParamCategory.ArgsList */ &&
1328
+ isParamSpec(secondLastParam.type) &&
1333
1329
  secondLastParam.type.priv.paramSpecAccess === 'args' &&
1334
- lastParam.category === 2 /* ParameterCategory.KwargsDict */ &&
1335
- isTypeVar(lastParam.type) &&
1330
+ lastParam.category === 2 /* ParamCategory.KwargsDict */ &&
1331
+ isParamSpec(lastParam.type) &&
1336
1332
  lastParam.type.priv.paramSpecAccess === 'kwargs') {
1337
1333
  return TypeVarType.cloneForParamSpecAccess(secondLastParam.type, /* access */ undefined);
1338
1334
  }
@@ -1340,16 +1336,16 @@ var FunctionType;
1340
1336
  }
1341
1337
  FunctionType.getParamSpecFromArgsKwargs = getParamSpecFromArgsKwargs;
1342
1338
  function addParamSpecVariadics(type, paramSpec) {
1343
- FunctionType.addParameter(type, FunctionParam.create(1 /* ParameterCategory.ArgsList */, TypeVarType.cloneForParamSpecAccess(paramSpec, 'args'), FunctionParamFlags.TypeDeclared, 'args'));
1344
- FunctionType.addParameter(type, FunctionParam.create(2 /* ParameterCategory.KwargsDict */, TypeVarType.cloneForParamSpecAccess(paramSpec, 'kwargs'), FunctionParamFlags.TypeDeclared, 'kwargs'));
1339
+ FunctionType.addParam(type, FunctionParam.create(1 /* ParamCategory.ArgsList */, TypeVarType.cloneForParamSpecAccess(paramSpec, 'args'), FunctionParamFlags.TypeDeclared, 'args'));
1340
+ FunctionType.addParam(type, FunctionParam.create(2 /* ParamCategory.KwargsDict */, TypeVarType.cloneForParamSpecAccess(paramSpec, 'kwargs'), FunctionParamFlags.TypeDeclared, 'kwargs'));
1345
1341
  }
1346
1342
  FunctionType.addParamSpecVariadics = addParamSpecVariadics;
1347
- function addDefaultParameters(type, useUnknown = false) {
1348
- getDefaultParameters(useUnknown).forEach((param) => {
1349
- FunctionType.addParameter(type, param);
1343
+ function addDefaultParams(type, useUnknown = false) {
1344
+ getDefaultParams(useUnknown).forEach((param) => {
1345
+ FunctionType.addParam(type, param);
1350
1346
  });
1351
1347
  }
1352
- FunctionType.addDefaultParameters = addDefaultParameters;
1348
+ FunctionType.addDefaultParams = addDefaultParams;
1353
1349
  function addHigherOrderTypeVarScopeIds(functionType, scopeIds) {
1354
1350
  if (!scopeIds) {
1355
1351
  return;
@@ -1371,15 +1367,15 @@ var FunctionType;
1371
1367
  });
1372
1368
  }
1373
1369
  FunctionType.addHigherOrderTypeVarScopeIds = addHigherOrderTypeVarScopeIds;
1374
- function getDefaultParameters(useUnknown = false) {
1370
+ function getDefaultParams(useUnknown = false) {
1375
1371
  return [
1376
- FunctionParam.create(1 /* ParameterCategory.ArgsList */, useUnknown ? UnknownType.create() : AnyType.create(), useUnknown ? FunctionParamFlags.None : FunctionParamFlags.TypeDeclared, 'args'),
1377
- FunctionParam.create(2 /* ParameterCategory.KwargsDict */, useUnknown ? UnknownType.create() : AnyType.create(), useUnknown ? FunctionParamFlags.None : FunctionParamFlags.TypeDeclared, 'kwargs'),
1372
+ FunctionParam.create(1 /* ParamCategory.ArgsList */, useUnknown ? UnknownType.create() : AnyType.create(), useUnknown ? FunctionParamFlags.None : FunctionParamFlags.TypeDeclared, 'args'),
1373
+ FunctionParam.create(2 /* ParamCategory.KwargsDict */, useUnknown ? UnknownType.create() : AnyType.create(), useUnknown ? FunctionParamFlags.None : FunctionParamFlags.TypeDeclared, 'kwargs'),
1378
1374
  ];
1379
1375
  }
1380
- FunctionType.getDefaultParameters = getDefaultParameters;
1376
+ FunctionType.getDefaultParams = getDefaultParams;
1381
1377
  // Indicates whether the input signature consists of (*args: Any, **kwargs: Any).
1382
- function hasDefaultParameters(functionType) {
1378
+ function hasDefaultParams(functionType) {
1383
1379
  let sawArgs = false;
1384
1380
  let sawKwargs = false;
1385
1381
  for (let i = 0; i < functionType.shared.parameters.length; i++) {
@@ -1388,22 +1384,22 @@ var FunctionType;
1388
1384
  if (!param.name) {
1389
1385
  continue;
1390
1386
  }
1391
- if (param.category === 0 /* ParameterCategory.Simple */) {
1387
+ if (param.category === 0 /* ParamCategory.Simple */) {
1392
1388
  return false;
1393
1389
  }
1394
- else if (param.category === 1 /* ParameterCategory.ArgsList */) {
1390
+ else if (param.category === 1 /* ParamCategory.ArgsList */) {
1395
1391
  sawArgs = true;
1396
1392
  }
1397
- else if (param.category === 2 /* ParameterCategory.KwargsDict */) {
1393
+ else if (param.category === 2 /* ParamCategory.KwargsDict */) {
1398
1394
  sawKwargs = true;
1399
1395
  }
1400
- if (!isAnyOrUnknown(FunctionType.getEffectiveParameterType(functionType, i))) {
1396
+ if (!isAnyOrUnknown(FunctionType.getEffectiveParamType(functionType, i))) {
1401
1397
  return false;
1402
1398
  }
1403
1399
  }
1404
1400
  return sawArgs && sawKwargs;
1405
1401
  }
1406
- FunctionType.hasDefaultParameters = hasDefaultParameters;
1402
+ FunctionType.hasDefaultParams = hasDefaultParams;
1407
1403
  function isInstanceMethod(type) {
1408
1404
  return ((type.shared.flags &
1409
1405
  (1 /* FunctionTypeFlags.ConstructorMethod */ |
@@ -1444,10 +1440,10 @@ var FunctionType;
1444
1440
  return (type.shared.flags & 256 /* FunctionTypeFlags.Overloaded */) !== 0;
1445
1441
  }
1446
1442
  FunctionType.isOverloaded = isOverloaded;
1447
- function isDefaultParameterCheckDisabled(type) {
1443
+ function isDefaultParamCheckDisabled(type) {
1448
1444
  return (type.shared.flags & 32 /* FunctionTypeFlags.DisableDefaultChecks */) !== 0;
1449
1445
  }
1450
- FunctionType.isDefaultParameterCheckDisabled = isDefaultParameterCheckDisabled;
1446
+ FunctionType.isDefaultParamCheckDisabled = isDefaultParamCheckDisabled;
1451
1447
  function isAsync(type) {
1452
1448
  return (type.shared.flags & 512 /* FunctionTypeFlags.Async */) !== 0;
1453
1449
  }
@@ -1495,15 +1491,15 @@ var FunctionType;
1495
1491
  return true;
1496
1492
  }
1497
1493
  FunctionType.isBuiltIn = isBuiltIn;
1498
- function getEffectiveParameterType(type, index) {
1494
+ function getEffectiveParamType(type, index) {
1499
1495
  (0, debug_1.assert)(index < type.shared.parameters.length, 'Parameter types array overflow');
1500
1496
  if (type.priv.specializedTypes && index < type.priv.specializedTypes.parameterTypes.length) {
1501
1497
  return type.priv.specializedTypes.parameterTypes[index];
1502
1498
  }
1503
1499
  return type.shared.parameters[index].type;
1504
1500
  }
1505
- FunctionType.getEffectiveParameterType = getEffectiveParameterType;
1506
- function getEffectiveParameterDefaultArgType(type, index) {
1501
+ FunctionType.getEffectiveParamType = getEffectiveParamType;
1502
+ function getEffectiveParamDefaultArgType(type, index) {
1507
1503
  var _a;
1508
1504
  (0, debug_1.assert)(index < type.shared.parameters.length, 'Parameter types array overflow');
1509
1505
  if (((_a = type.priv.specializedTypes) === null || _a === void 0 ? void 0 : _a.parameterDefaultArgs) &&
@@ -1515,22 +1511,22 @@ var FunctionType;
1515
1511
  }
1516
1512
  return type.shared.parameters[index].defaultType;
1517
1513
  }
1518
- FunctionType.getEffectiveParameterDefaultArgType = getEffectiveParameterDefaultArgType;
1519
- function addParameter(type, param) {
1514
+ FunctionType.getEffectiveParamDefaultArgType = getEffectiveParamDefaultArgType;
1515
+ function addParam(type, param) {
1520
1516
  type.shared.parameters.push(param);
1521
1517
  if (type.priv.specializedTypes) {
1522
1518
  type.priv.specializedTypes.parameterTypes.push(param.type);
1523
1519
  }
1524
1520
  }
1525
- FunctionType.addParameter = addParameter;
1526
- function addPositionOnlyParameterSeparator(type) {
1527
- addParameter(type, FunctionParam.create(0 /* ParameterCategory.Simple */, AnyType.create()));
1521
+ FunctionType.addParam = addParam;
1522
+ function addPositionOnlyParamSeparator(type) {
1523
+ addParam(type, FunctionParam.create(0 /* ParamCategory.Simple */, AnyType.create()));
1528
1524
  }
1529
- FunctionType.addPositionOnlyParameterSeparator = addPositionOnlyParameterSeparator;
1530
- function addKeywordOnlyParameterSeparator(type) {
1531
- addParameter(type, FunctionParam.create(1 /* ParameterCategory.ArgsList */, AnyType.create()));
1525
+ FunctionType.addPositionOnlyParamSeparator = addPositionOnlyParamSeparator;
1526
+ function addKeywordOnlyParamSeparator(type) {
1527
+ addParam(type, FunctionParam.create(1 /* ParamCategory.ArgsList */, AnyType.create()));
1532
1528
  }
1533
- FunctionType.addKeywordOnlyParameterSeparator = addKeywordOnlyParameterSeparator;
1529
+ FunctionType.addKeywordOnlyParamSeparator = addKeywordOnlyParamSeparator;
1534
1530
  function getEffectiveReturnType(type, includeInferred = true) {
1535
1531
  var _a;
1536
1532
  if ((_a = type.priv.specializedTypes) === null || _a === void 0 ? void 0 : _a.returnType) {
@@ -1857,20 +1853,36 @@ var Variance;
1857
1853
  Variance[Variance["Covariant"] = 3] = "Covariant";
1858
1854
  Variance[Variance["Contravariant"] = 4] = "Contravariant";
1859
1855
  })(Variance || (exports.Variance = Variance = {}));
1856
+ var TypeVarKind;
1857
+ (function (TypeVarKind) {
1858
+ TypeVarKind[TypeVarKind["TypeVar"] = 0] = "TypeVar";
1859
+ TypeVarKind[TypeVarKind["TypeVarTuple"] = 1] = "TypeVarTuple";
1860
+ TypeVarKind[TypeVarKind["ParamSpec"] = 2] = "ParamSpec";
1861
+ })(TypeVarKind || (exports.TypeVarKind = TypeVarKind = {}));
1860
1862
  var TypeVarScopeType;
1861
1863
  (function (TypeVarScopeType) {
1862
1864
  TypeVarScopeType[TypeVarScopeType["Class"] = 0] = "Class";
1863
1865
  TypeVarScopeType[TypeVarScopeType["Function"] = 1] = "Function";
1864
1866
  TypeVarScopeType[TypeVarScopeType["TypeAlias"] = 2] = "TypeAlias";
1865
1867
  })(TypeVarScopeType || (exports.TypeVarScopeType = TypeVarScopeType = {}));
1868
+ var ParamSpecType;
1869
+ (function (ParamSpecType) {
1870
+ // Returns the "Unknown" equivalent for a ParamSpec.
1871
+ function getUnknown() {
1872
+ const newFunction = FunctionType.createInstance('', '', '', 65536 /* FunctionTypeFlags.ParamSpecValue */ | 32768 /* FunctionTypeFlags.GradualCallableForm */);
1873
+ FunctionType.addDefaultParams(newFunction);
1874
+ return newFunction;
1875
+ }
1876
+ ParamSpecType.getUnknown = getUnknown;
1877
+ })(ParamSpecType || (exports.ParamSpecType = ParamSpecType = {}));
1866
1878
  var TypeVarType;
1867
1879
  (function (TypeVarType) {
1868
- function createInstance(name) {
1869
- return create(name, /* isParamSpec */ false, 2 /* TypeFlags.Instance */);
1880
+ function createInstance(name, kind = TypeVarKind.TypeVar) {
1881
+ return create(name, kind, 2 /* TypeFlags.Instance */);
1870
1882
  }
1871
1883
  TypeVarType.createInstance = createInstance;
1872
- function createInstantiable(name, isParamSpec = false) {
1873
- return create(name, isParamSpec, 1 /* TypeFlags.Instantiable */);
1884
+ function createInstantiable(name, kind = TypeVarKind.TypeVar) {
1885
+ return create(name, kind, 1 /* TypeFlags.Instantiable */);
1874
1886
  }
1875
1887
  TypeVarType.createInstantiable = createInstantiable;
1876
1888
  function cloneAsInstance(type) {
@@ -1883,6 +1895,9 @@ var TypeVarType;
1883
1895
  if ((_b = newInstance.props) === null || _b === void 0 ? void 0 : _b.specialForm) {
1884
1896
  TypeBase.setSpecialForm(newInstance, undefined);
1885
1897
  }
1898
+ if (newInstance.priv.externalTypeVar) {
1899
+ newInstance.priv.externalTypeVar = TypeVarType.cloneAsInstance(newInstance.priv.externalTypeVar);
1900
+ }
1886
1901
  return newInstance;
1887
1902
  }
1888
1903
  TypeVarType.cloneAsInstance = cloneAsInstance;
@@ -1892,6 +1907,9 @@ var TypeVarType;
1892
1907
  return type.cached.typeBaseInstantiableType;
1893
1908
  }
1894
1909
  const newInstance = TypeBase.cloneTypeAsInstantiable(type, /* cache */ true);
1910
+ if (newInstance.priv.externalTypeVar) {
1911
+ newInstance.priv.externalTypeVar = TypeVarType.cloneAsInstantiable(newInstance.priv.externalTypeVar);
1912
+ }
1895
1913
  return newInstance;
1896
1914
  }
1897
1915
  TypeVarType.cloneAsInstantiable = cloneAsInstantiable;
@@ -1915,18 +1933,22 @@ var TypeVarType;
1915
1933
  }
1916
1934
  TypeVarType.cloneForScopeId = cloneForScopeId;
1917
1935
  function cloneForUnpacked(type, isInUnion = false) {
1918
- (0, debug_1.assert)(type.shared.isVariadic);
1919
1936
  const newInstance = TypeBase.cloneType(type);
1920
1937
  newInstance.priv.isVariadicUnpacked = true;
1921
1938
  newInstance.priv.isVariadicInUnion = isInUnion;
1939
+ if (newInstance.priv.externalTypeVar) {
1940
+ newInstance.priv.externalTypeVar = TypeVarType.cloneForUnpacked(newInstance.priv.externalTypeVar, isInUnion);
1941
+ }
1922
1942
  return newInstance;
1923
1943
  }
1924
1944
  TypeVarType.cloneForUnpacked = cloneForUnpacked;
1925
1945
  function cloneForPacked(type) {
1926
- (0, debug_1.assert)(type.shared.isVariadic);
1927
1946
  const newInstance = TypeBase.cloneType(type);
1928
1947
  newInstance.priv.isVariadicUnpacked = false;
1929
1948
  newInstance.priv.isVariadicInUnion = false;
1949
+ if (newInstance.priv.externalTypeVar) {
1950
+ newInstance.priv.externalTypeVar = TypeVarType.cloneForPacked(newInstance.priv.externalTypeVar);
1951
+ }
1930
1952
  return newInstance;
1931
1953
  }
1932
1954
  TypeVarType.cloneForPacked = cloneForPacked;
@@ -1934,7 +1956,7 @@ var TypeVarType;
1934
1956
  // and no bound or constraints. ParamSpecs and variadics are left
1935
1957
  // unmodified. So are auto-variant type variables.
1936
1958
  function cloneAsInvariant(type) {
1937
- if (type.shared.isParamSpec || type.shared.isVariadic) {
1959
+ if (isParamSpec(type) || isTypeVarTuple(type)) {
1938
1960
  return type;
1939
1961
  }
1940
1962
  if (type.shared.declaredVariance === 0 /* Variance.Auto */) {
@@ -1990,20 +2012,39 @@ var TypeVarType;
1990
2012
  return `${name}.${scopeId}`;
1991
2013
  }
1992
2014
  TypeVarType.makeNameWithScope = makeNameWithScope;
1993
- function create(name, isParamSpec, typeFlags) {
2015
+ function makeInternalScopeId(scopeId) {
2016
+ if (!scopeId) {
2017
+ return undefined;
2018
+ }
2019
+ return `${scopeId}*`;
2020
+ }
2021
+ TypeVarType.makeInternalScopeId = makeInternalScopeId;
2022
+ function cloneWithInternalScopeId(type) {
2023
+ if (type.priv.scopeId === undefined || type.priv.externalTypeVar) {
2024
+ return type;
2025
+ }
2026
+ const clone = TypeVarType.cloneForScopeId(type, TypeVarType.makeInternalScopeId(type.priv.scopeId), type.priv.scopeName, type.priv.scopeType);
2027
+ clone.priv.externalTypeVar = type;
2028
+ return clone;
2029
+ }
2030
+ TypeVarType.cloneWithInternalScopeId = cloneWithInternalScopeId;
2031
+ function hasInternalScopeId(type) {
2032
+ return !!type.priv.externalTypeVar;
2033
+ }
2034
+ TypeVarType.hasInternalScopeId = hasInternalScopeId;
2035
+ function create(name, kind, typeFlags) {
1994
2036
  const newTypeVarType = {
1995
2037
  category: 9 /* TypeCategory.TypeVar */,
1996
2038
  flags: typeFlags,
1997
2039
  props: undefined,
1998
2040
  cached: undefined,
1999
2041
  shared: {
2042
+ kind,
2000
2043
  name,
2001
2044
  constraints: [],
2002
2045
  boundType: undefined,
2003
2046
  isDefaultExplicit: false,
2004
2047
  defaultType: UnknownType.create(),
2005
- isParamSpec,
2006
- isVariadic: false,
2007
2048
  declaredVariance: 2 /* Variance.Invariant */,
2008
2049
  isSynthesized: false,
2009
2050
  isSynthesizedSelf: false,
@@ -2016,8 +2057,8 @@ var TypeVarType;
2016
2057
  };
2017
2058
  return newTypeVarType;
2018
2059
  }
2019
- function addConstraint(typeVarType, constraintType) {
2020
- typeVarType.shared.constraints.push(constraintType);
2060
+ function addConstraint(type, constraintType) {
2061
+ type.shared.constraints.push(constraintType);
2021
2062
  }
2022
2063
  TypeVarType.addConstraint = addConstraint;
2023
2064
  function getNameWithScope(typeVarType) {
@@ -2025,11 +2066,11 @@ var TypeVarType;
2025
2066
  return typeVarType.priv.nameWithScope || typeVarType.shared.name;
2026
2067
  }
2027
2068
  TypeVarType.getNameWithScope = getNameWithScope;
2028
- function getReadableName(typeVarType) {
2029
- if (typeVarType.priv.scopeName) {
2030
- return `${typeVarType.shared.name}@${typeVarType.priv.scopeName}`;
2069
+ function getReadableName(type) {
2070
+ if (type.priv.scopeName) {
2071
+ return `${type.shared.name}@${type.priv.scopeName}`;
2031
2072
  }
2032
- return typeVarType.shared.name;
2073
+ return type.shared.name;
2033
2074
  }
2034
2075
  TypeVarType.getReadableName = getReadableName;
2035
2076
  function getVariance(type) {
@@ -2112,17 +2153,18 @@ function isTypeVar(type) {
2112
2153
  return type.category === 9 /* TypeCategory.TypeVar */;
2113
2154
  }
2114
2155
  exports.isTypeVar = isTypeVar;
2115
- function isVariadicTypeVar(type) {
2116
- return type.category === 9 /* TypeCategory.TypeVar */ && type.shared.isVariadic;
2156
+ function isParamSpec(type) {
2157
+ return type.category === 9 /* TypeCategory.TypeVar */ && type.shared.kind === TypeVarKind.ParamSpec;
2158
+ }
2159
+ exports.isParamSpec = isParamSpec;
2160
+ function isTypeVarTuple(type) {
2161
+ return type.category === 9 /* TypeCategory.TypeVar */ && type.shared.kind === TypeVarKind.TypeVarTuple;
2117
2162
  }
2118
- exports.isVariadicTypeVar = isVariadicTypeVar;
2119
- function isUnpackedVariadicTypeVar(type) {
2120
- return (type.category === 9 /* TypeCategory.TypeVar */ &&
2121
- type.shared.isVariadic &&
2122
- !!type.priv.isVariadicUnpacked &&
2123
- !type.priv.isVariadicInUnion);
2163
+ exports.isTypeVarTuple = isTypeVarTuple;
2164
+ function isUnpackedTypeVarTuple(type) {
2165
+ return isTypeVarTuple(type) && !!type.priv.isVariadicUnpacked && !type.priv.isVariadicInUnion;
2124
2166
  }
2125
- exports.isUnpackedVariadicTypeVar = isUnpackedVariadicTypeVar;
2167
+ exports.isUnpackedTypeVarTuple = isUnpackedTypeVarTuple;
2126
2168
  function isUnpackedClass(type) {
2127
2169
  if (!isClass(type) || !type.priv.isUnpacked) {
2128
2170
  return false;
@@ -2131,13 +2173,9 @@ function isUnpackedClass(type) {
2131
2173
  }
2132
2174
  exports.isUnpackedClass = isUnpackedClass;
2133
2175
  function isUnpacked(type) {
2134
- return isUnpackedVariadicTypeVar(type) || isUnpackedClass(type);
2176
+ return isUnpackedTypeVarTuple(type) || isUnpackedClass(type);
2135
2177
  }
2136
2178
  exports.isUnpacked = isUnpacked;
2137
- function isParamSpec(type) {
2138
- return type.category === 9 /* TypeCategory.TypeVar */ && type.shared.isParamSpec;
2139
- }
2140
- exports.isParamSpec = isParamSpec;
2141
2179
  function isFunction(type) {
2142
2180
  return type.category === 4 /* TypeCategory.Function */;
2143
2181
  }
@@ -2200,9 +2238,9 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2200
2238
  }
2201
2239
  if (!options.ignorePseudoGeneric || !ClassType.isPseudoGenericClass(type1)) {
2202
2240
  // Make sure the type args match.
2203
- if (type1.priv.tupleTypeArguments && classType2.priv.tupleTypeArguments) {
2204
- const type1TupleTypeArgs = type1.priv.tupleTypeArguments || [];
2205
- const type2TupleTypeArgs = classType2.priv.tupleTypeArguments || [];
2241
+ if (type1.priv.tupleTypeArgs && classType2.priv.tupleTypeArgs) {
2242
+ const type1TupleTypeArgs = type1.priv.tupleTypeArgs || [];
2243
+ const type2TupleTypeArgs = classType2.priv.tupleTypeArgs || [];
2206
2244
  if (type1TupleTypeArgs.length !== type2TupleTypeArgs.length) {
2207
2245
  return false;
2208
2246
  }
@@ -2216,8 +2254,8 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2216
2254
  }
2217
2255
  }
2218
2256
  else {
2219
- const type1TypeArgs = type1.priv.typeArguments || [];
2220
- const type2TypeArgs = classType2.priv.typeArguments || [];
2257
+ const type1TypeArgs = type1.priv.typeArgs || [];
2258
+ const type2TypeArgs = classType2.priv.typeArgs || [];
2221
2259
  const typeArgCount = Math.max(type1TypeArgs.length, type2TypeArgs.length);
2222
2260
  for (let i = 0; i < typeArgCount; i++) {
2223
2261
  // Assume that missing type args are "Unknown".
@@ -2277,8 +2315,8 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2277
2315
  else if (isKeywordOnlySeparator(param1) && isKeywordOnlySeparator(param2)) {
2278
2316
  continue;
2279
2317
  }
2280
- const param1Type = FunctionType.getEffectiveParameterType(type1, i);
2281
- const param2Type = FunctionType.getEffectiveParameterType(functionType2, i);
2318
+ const param1Type = FunctionType.getEffectiveParamType(type1, i);
2319
+ const param2Type = FunctionType.getEffectiveParamType(functionType2, i);
2282
2320
  if (!isTypeSame(param1Type, param2Type, { ...options, ignoreTypeFlags: false }, recursionCount)) {
2283
2321
  return false;
2284
2322
  }
@@ -2342,8 +2380,8 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2342
2380
  // Handle the case where this is a generic recursive type alias. Make
2343
2381
  // sure that the type argument types match.
2344
2382
  if (type1.shared.recursiveAlias && type2TypeVar.shared.recursiveAlias) {
2345
- const type1TypeArgs = ((_d = (_c = type1 === null || type1 === void 0 ? void 0 : type1.props) === null || _c === void 0 ? void 0 : _c.typeAliasInfo) === null || _d === void 0 ? void 0 : _d.typeArguments) || [];
2346
- const type2TypeArgs = ((_f = (_e = type2 === null || type2 === void 0 ? void 0 : type2.props) === null || _e === void 0 ? void 0 : _e.typeAliasInfo) === null || _f === void 0 ? void 0 : _f.typeArguments) || [];
2383
+ const type1TypeArgs = ((_d = (_c = type1 === null || type1 === void 0 ? void 0 : type1.props) === null || _c === void 0 ? void 0 : _c.typeAliasInfo) === null || _d === void 0 ? void 0 : _d.typeArgs) || [];
2384
+ const type2TypeArgs = ((_f = (_e = type2 === null || type2 === void 0 ? void 0 : type2.props) === null || _e === void 0 ? void 0 : _e.typeAliasInfo) === null || _f === void 0 ? void 0 : _f.typeArgs) || [];
2347
2385
  const typeArgCount = Math.max(type1TypeArgs.length, type2TypeArgs.length);
2348
2386
  for (let i = 0; i < typeArgCount; i++) {
2349
2387
  // Assume that missing type args are "Any".
@@ -2354,15 +2392,21 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
2354
2392
  }
2355
2393
  }
2356
2394
  }
2357
- if (!type1.priv.isVariadicInUnion !== !type2TypeVar.priv.isVariadicInUnion) {
2358
- return false;
2395
+ if (isTypeVarTuple(type1) && isTypeVarTuple(type2TypeVar)) {
2396
+ if (!type1.priv.isVariadicInUnion !== !type2TypeVar.priv.isVariadicInUnion) {
2397
+ return false;
2398
+ }
2359
2399
  }
2360
2400
  if (type1.shared === type2TypeVar.shared) {
2361
2401
  return true;
2362
2402
  }
2403
+ if (isParamSpec(type1) !== isParamSpec(type2TypeVar)) {
2404
+ return false;
2405
+ }
2406
+ if (isTypeVarTuple(type1) !== isTypeVarTuple(type2TypeVar)) {
2407
+ return false;
2408
+ }
2363
2409
  if (type1.shared.name !== type2TypeVar.shared.name ||
2364
- type1.shared.isParamSpec !== type2TypeVar.shared.isParamSpec ||
2365
- type1.shared.isVariadic !== type2TypeVar.shared.isVariadic ||
2366
2410
  type1.shared.isSynthesized !== type2TypeVar.shared.isSynthesized ||
2367
2411
  type1.shared.declaredVariance !== type2TypeVar.shared.declaredVariance ||
2368
2412
  type1.priv.scopeId !== type2TypeVar.priv.scopeId) {
@@ -2632,8 +2676,7 @@ function _addTypeIfUnique(unionType, typeToAdd, elideRedundantLiterals) {
2632
2676
  // parameterized with its own class) ad infinitum.
2633
2677
  if (isPseudoGeneric) {
2634
2678
  if (isTypeSame(type, typeToAdd, { ignorePseudoGeneric: true })) {
2635
- unionType.priv.subtypes[i] = ClassType.cloneForSpecialization(typeToAdd, typeToAdd.shared.typeParameters.map(() => UnknownType.create()),
2636
- /* isTypeArgumentExplicit */ true);
2679
+ unionType.priv.subtypes[i] = ClassType.specialize(typeToAdd, typeToAdd.shared.typeParams.map(() => UnknownType.create()));
2637
2680
  return;
2638
2681
  }
2639
2682
  }
@@ -2661,7 +2704,7 @@ function _addTypeIfUnique(unionType, typeToAdd, elideRedundantLiterals) {
2661
2704
  // existing type, see if one of them is a proper subset of the other.
2662
2705
  if (ClassType.isTypedDictClass(type) && ClassType.isSameGenericClass(type, typeToAdd)) {
2663
2706
  // Do not proceed if the TypedDicts are generic and have different type arguments.
2664
- if (!type.priv.typeArguments && !typeToAdd.priv.typeArguments) {
2707
+ if (!type.priv.typeArgs && !typeToAdd.priv.typeArgs) {
2665
2708
  if (ClassType.isTypedDictNarrower(typeToAdd, type)) {
2666
2709
  return;
2667
2710
  }