@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.
- package/dist/analyzer/analyzerNodeInfo.js +2 -2
- package/dist/analyzer/analyzerNodeInfo.js.map +1 -1
- package/dist/analyzer/binder.js +8 -8
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/cacheManager.js +3 -0
- package/dist/analyzer/cacheManager.js.map +1 -1
- package/dist/analyzer/checker.d.ts +3 -2
- package/dist/analyzer/checker.js +137 -142
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.d.ts +2 -2
- package/dist/analyzer/codeFlowEngine.js +74 -44
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/codeFlowTypes.js +1 -1
- package/dist/analyzer/codeFlowTypes.js.map +1 -1
- package/dist/analyzer/constraintSolver.d.ts +2 -2
- package/dist/analyzer/constraintSolver.js +166 -206
- package/dist/analyzer/constraintSolver.js.map +1 -1
- package/dist/analyzer/constructorTransform.d.ts +2 -3
- package/dist/analyzer/constructorTransform.js +18 -19
- package/dist/analyzer/constructorTransform.js.map +1 -1
- package/dist/analyzer/constructors.d.ts +3 -3
- package/dist/analyzer/constructors.js +72 -175
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/dataClasses.d.ts +2 -2
- package/dist/analyzer/dataClasses.js +60 -40
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/declaration.d.ts +9 -9
- package/dist/analyzer/declaration.js +9 -9
- package/dist/analyzer/declaration.js.map +1 -1
- package/dist/analyzer/declarationUtils.d.ts +1 -1
- package/dist/analyzer/declarationUtils.js +6 -6
- package/dist/analyzer/declarationUtils.js.map +1 -1
- package/dist/analyzer/decorators.js +5 -6
- package/dist/analyzer/decorators.js.map +1 -1
- package/dist/analyzer/docStringConversion.js +2 -2
- package/dist/analyzer/docStringConversion.js.map +1 -1
- package/dist/analyzer/enums.d.ts +2 -2
- package/dist/analyzer/enums.js +6 -6
- package/dist/analyzer/enums.js.map +1 -1
- package/dist/analyzer/functionTransform.d.ts +2 -2
- package/dist/analyzer/functionTransform.js +4 -4
- package/dist/analyzer/functionTransform.js.map +1 -1
- package/dist/analyzer/importResolver.js +5 -3
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/namedTuples.d.ts +3 -3
- package/dist/analyzer/namedTuples.js +21 -22
- package/dist/analyzer/namedTuples.js.map +1 -1
- package/dist/analyzer/operations.js +145 -96
- package/dist/analyzer/operations.js.map +1 -1
- package/dist/analyzer/packageTypeVerifier.js +8 -8
- package/dist/analyzer/packageTypeVerifier.js.map +1 -1
- package/dist/analyzer/parameterUtils.d.ts +10 -10
- package/dist/analyzer/parameterUtils.js +60 -59
- package/dist/analyzer/parameterUtils.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.d.ts +7 -6
- package/dist/analyzer/parseTreeUtils.js +47 -24
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/patternMatching.js +109 -90
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/program.js +11 -4
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/properties.js +23 -19
- package/dist/analyzer/properties.js.map +1 -1
- package/dist/analyzer/protocols.js +23 -20
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/pythonPathUtils.js +1 -1
- package/dist/analyzer/pythonPathUtils.js.map +1 -1
- package/dist/analyzer/service.d.ts +3 -7
- package/dist/analyzer/service.js +28 -30
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/serviceUtils.d.ts +8 -0
- package/dist/analyzer/serviceUtils.js +31 -0
- package/dist/analyzer/serviceUtils.js.map +1 -0
- package/dist/analyzer/sourceFile.js +5 -19
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/sourceMapper.d.ts +1 -1
- package/dist/analyzer/sourceMapper.js +4 -4
- package/dist/analyzer/sourceMapper.js.map +1 -1
- package/dist/analyzer/staticExpressions.js +1 -1
- package/dist/analyzer/staticExpressions.js.map +1 -1
- package/dist/analyzer/testWalker.js +13 -1
- package/dist/analyzer/testWalker.js.map +1 -1
- package/dist/analyzer/tracePrinter.js +4 -4
- package/dist/analyzer/tracePrinter.js.map +1 -1
- package/dist/analyzer/tuples.d.ts +9 -0
- package/dist/analyzer/tuples.js +252 -0
- package/dist/analyzer/tuples.js.map +1 -0
- package/dist/analyzer/typeComplexity.d.ts +2 -0
- package/dist/analyzer/typeComplexity.js +86 -0
- package/dist/analyzer/typeComplexity.js.map +1 -0
- package/dist/analyzer/typeEvaluator.js +1721 -1824
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +47 -40
- package/dist/analyzer/typeEvaluatorTypes.js +10 -1
- package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
- package/dist/analyzer/typeGuards.js +116 -90
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typePrinter.d.ts +1 -1
- package/dist/analyzer/typePrinter.js +54 -53
- package/dist/analyzer/typePrinter.js.map +1 -1
- package/dist/analyzer/typeStubWriter.d.ts +3 -3
- package/dist/analyzer/typeStubWriter.js +15 -15
- package/dist/analyzer/typeStubWriter.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +35 -29
- package/dist/analyzer/typeUtils.js +420 -357
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typeVarContext.d.ts +24 -36
- package/dist/analyzer/typeVarContext.js +89 -193
- package/dist/analyzer/typeVarContext.js.map +1 -1
- package/dist/analyzer/typeWalker.js +4 -4
- package/dist/analyzer/typeWalker.js.map +1 -1
- package/dist/analyzer/typedDicts.d.ts +2 -2
- package/dist/analyzer/typedDicts.js +49 -53
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.d.ts +89 -63
- package/dist/analyzer/types.js +163 -120
- package/dist/analyzer/types.js.map +1 -1
- package/dist/commands/dumpFileDebugInfoCommand.js +12 -12
- package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
- package/dist/common/configOptions.d.ts +1 -0
- package/dist/common/configOptions.js +5 -0
- package/dist/common/configOptions.js.map +1 -1
- package/dist/common/diagnosticRules.d.ts +1 -0
- package/dist/common/diagnosticRules.js +1 -0
- package/dist/common/diagnosticRules.js.map +1 -1
- package/dist/common/fileSystem.d.ts +0 -1
- package/dist/common/fileSystem.js.map +1 -1
- package/dist/common/languageServerInterface.d.ts +13 -0
- package/dist/common/languageServerInterface.js +15 -1
- package/dist/common/languageServerInterface.js.map +1 -1
- package/dist/common/lspUtils.js +2 -2
- package/dist/common/memUtils.d.ts +4 -0
- package/dist/common/memUtils.js +33 -2
- package/dist/common/memUtils.js.map +1 -1
- package/dist/common/serviceKeys.d.ts +3 -0
- package/dist/common/serviceKeys.js +2 -0
- package/dist/common/serviceKeys.js.map +1 -1
- package/dist/common/serviceProviderExtensions.js +7 -0
- package/dist/common/serviceProviderExtensions.js.map +1 -1
- package/dist/languageServerBase.d.ts +4 -3
- package/dist/languageServerBase.js +14 -10
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/autoImporter.d.ts +3 -2
- package/dist/languageService/autoImporter.js +5 -1
- package/dist/languageService/autoImporter.js.map +1 -1
- package/dist/languageService/completionProvider.d.ts +5 -3
- package/dist/languageService/completionProvider.js +38 -37
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/completionProviderUtils.d.ts +1 -1
- package/dist/languageService/completionProviderUtils.js +3 -3
- package/dist/languageService/completionProviderUtils.js.map +1 -1
- package/dist/languageService/fileWatcherDynamicFeature.js +2 -2
- package/dist/languageService/fileWatcherDynamicFeature.js.map +1 -1
- package/dist/languageService/hoverProvider.js +14 -6
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/languageService/referencesProvider.d.ts +10 -4
- package/dist/languageService/referencesProvider.js +24 -12
- package/dist/languageService/referencesProvider.js.map +1 -1
- package/dist/languageService/renameProvider.js +21 -4
- package/dist/languageService/renameProvider.js.map +1 -1
- package/dist/languageService/signatureHelpProvider.js +1 -1
- package/dist/languageService/signatureHelpProvider.js.map +1 -1
- package/dist/languageService/tooltipUtils.js +3 -3
- package/dist/languageService/tooltipUtils.js.map +1 -1
- package/dist/localization/localize.d.ts +9 -3
- package/dist/localization/localize.js +8 -1
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.cs.json +5 -2
- package/dist/localization/package.nls.de.json +5 -2
- package/dist/localization/package.nls.en-us.json +7 -1
- package/dist/localization/package.nls.es.json +5 -2
- package/dist/localization/package.nls.fr.json +5 -2
- package/dist/localization/package.nls.it.json +5 -2
- package/dist/localization/package.nls.ja.json +5 -2
- package/dist/localization/package.nls.ko.json +5 -2
- package/dist/localization/package.nls.pl.json +5 -2
- package/dist/localization/package.nls.pt-br.json +5 -2
- package/dist/localization/package.nls.qps-ploc.json +5 -2
- package/dist/localization/package.nls.ru.json +5 -2
- package/dist/localization/package.nls.tr.json +5 -2
- package/dist/localization/package.nls.zh-cn.json +5 -2
- package/dist/localization/package.nls.zh-tw.json +5 -2
- package/dist/parser/parseNodes.d.ts +12 -10
- package/dist/parser/parseNodes.js +23 -21
- package/dist/parser/parseNodes.js.map +1 -1
- package/dist/parser/parser.js +66 -43
- package/dist/parser/parser.js.map +1 -1
- package/dist/tests/checker.test.js +2 -2
- package/dist/tests/fourslash/rename.args.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/rename.args.fourslash.js +71 -0
- package/dist/tests/fourslash/rename.args.fourslash.js.map +1 -0
- package/dist/tests/fourslash/signature.builtinDocstrings.fourslash.js +4 -21
- package/dist/tests/fourslash/signature.builtinDocstrings.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.complicated.fourslash.js +1 -1
- package/dist/tests/fourslash/signature.complicated.fourslash.js.map +1 -1
- package/dist/tests/harness/fourslash/fourSlashParser.js +1 -1
- package/dist/tests/harness/fourslash/fourSlashParser.js.map +1 -1
- package/dist/tests/harness/fourslash/testStateUtils.js +2 -2
- package/dist/tests/harness/fourslash/testStateUtils.js.map +1 -1
- package/dist/tests/harness/vfs/filesystem.d.ts +0 -1
- package/dist/tests/harness/vfs/filesystem.js +0 -4
- package/dist/tests/harness/vfs/filesystem.js.map +1 -1
- package/dist/tests/importResolver.test.js +62 -15
- package/dist/tests/importResolver.test.js.map +1 -1
- package/dist/tests/lsp/languageServerTestUtils.js +1 -1
- package/dist/tests/lsp/languageServerTestUtils.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +17 -0
- package/dist/tests/typeEvaluator1.test.js.map +1 -1
- package/dist/tests/typeEvaluator2.test.js +4 -0
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +1 -1
- package/dist/tests/typeEvaluator4.test.js +19 -7
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/dist/tests/typeEvaluator5.test.js +8 -2
- package/dist/tests/typeEvaluator5.test.js.map +1 -1
- package/dist/tests/typeEvaluator6.test.js +76 -60
- package/dist/tests/typeEvaluator6.test.js.map +1 -1
- package/dist/tests/typeEvaluator7.test.js +5 -1
- package/dist/tests/typeEvaluator7.test.js.map +1 -1
- package/dist/tests/typePrinter.test.js +13 -18
- package/dist/tests/typePrinter.test.js.map +1 -1
- package/dist/workspaceFactory.d.ts +3 -2
- package/dist/workspaceFactory.js +15 -2
- package/dist/workspaceFactory.js.map +1 -1
- package/package.json +1 -1
package/dist/analyzer/types.js
CHANGED
@@ -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.
|
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
|
-
|
198
|
+
typeParams: typeParams,
|
199
199
|
usageVariance: undefined,
|
200
|
-
|
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
|
-
|
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
|
483
|
+
function specialize(classType, typeArgs, isTypeArgExplicit, includeSubclasses = false, tupleTypeArgs, isEmptyContainer) {
|
484
484
|
const newClassType = TypeBase.cloneType(classType);
|
485
|
-
newClassType.priv.
|
486
|
-
|
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.
|
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.
|
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.
|
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
|
817
|
-
return classType.shared.
|
814
|
+
function getTypeParams(classType) {
|
815
|
+
return classType.shared.typeParams;
|
818
816
|
}
|
819
|
-
ClassType.
|
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.
|
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.
|
892
|
-
if (!isTypeSame(class1Details.
|
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 /*
|
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 /*
|
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
|
-
|
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 /*
|
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 =
|
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
|
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.
|
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.
|
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,
|
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.
|
1253
|
-
newFunction.priv.
|
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 /*
|
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.
|
1290
|
-
const kwargsType = FunctionType.
|
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 /*
|
1332
|
-
|
1327
|
+
if (secondLastParam.category === 1 /* ParamCategory.ArgsList */ &&
|
1328
|
+
isParamSpec(secondLastParam.type) &&
|
1333
1329
|
secondLastParam.type.priv.paramSpecAccess === 'args' &&
|
1334
|
-
lastParam.category === 2 /*
|
1335
|
-
|
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.
|
1344
|
-
FunctionType.
|
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
|
1348
|
-
|
1349
|
-
FunctionType.
|
1343
|
+
function addDefaultParams(type, useUnknown = false) {
|
1344
|
+
getDefaultParams(useUnknown).forEach((param) => {
|
1345
|
+
FunctionType.addParam(type, param);
|
1350
1346
|
});
|
1351
1347
|
}
|
1352
|
-
FunctionType.
|
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
|
1370
|
+
function getDefaultParams(useUnknown = false) {
|
1375
1371
|
return [
|
1376
|
-
FunctionParam.create(1 /*
|
1377
|
-
FunctionParam.create(2 /*
|
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.
|
1376
|
+
FunctionType.getDefaultParams = getDefaultParams;
|
1381
1377
|
// Indicates whether the input signature consists of (*args: Any, **kwargs: Any).
|
1382
|
-
function
|
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 /*
|
1387
|
+
if (param.category === 0 /* ParamCategory.Simple */) {
|
1392
1388
|
return false;
|
1393
1389
|
}
|
1394
|
-
else if (param.category === 1 /*
|
1390
|
+
else if (param.category === 1 /* ParamCategory.ArgsList */) {
|
1395
1391
|
sawArgs = true;
|
1396
1392
|
}
|
1397
|
-
else if (param.category === 2 /*
|
1393
|
+
else if (param.category === 2 /* ParamCategory.KwargsDict */) {
|
1398
1394
|
sawKwargs = true;
|
1399
1395
|
}
|
1400
|
-
if (!isAnyOrUnknown(FunctionType.
|
1396
|
+
if (!isAnyOrUnknown(FunctionType.getEffectiveParamType(functionType, i))) {
|
1401
1397
|
return false;
|
1402
1398
|
}
|
1403
1399
|
}
|
1404
1400
|
return sawArgs && sawKwargs;
|
1405
1401
|
}
|
1406
|
-
FunctionType.
|
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
|
1443
|
+
function isDefaultParamCheckDisabled(type) {
|
1448
1444
|
return (type.shared.flags & 32 /* FunctionTypeFlags.DisableDefaultChecks */) !== 0;
|
1449
1445
|
}
|
1450
|
-
FunctionType.
|
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
|
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.
|
1506
|
-
function
|
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.
|
1519
|
-
function
|
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.
|
1526
|
-
function
|
1527
|
-
|
1521
|
+
FunctionType.addParam = addParam;
|
1522
|
+
function addPositionOnlyParamSeparator(type) {
|
1523
|
+
addParam(type, FunctionParam.create(0 /* ParamCategory.Simple */, AnyType.create()));
|
1528
1524
|
}
|
1529
|
-
FunctionType.
|
1530
|
-
function
|
1531
|
-
|
1525
|
+
FunctionType.addPositionOnlyParamSeparator = addPositionOnlyParamSeparator;
|
1526
|
+
function addKeywordOnlyParamSeparator(type) {
|
1527
|
+
addParam(type, FunctionParam.create(1 /* ParamCategory.ArgsList */, AnyType.create()));
|
1532
1528
|
}
|
1533
|
-
FunctionType.
|
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,
|
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,
|
1873
|
-
return create(name,
|
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
|
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
|
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(
|
2020
|
-
|
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(
|
2029
|
-
if (
|
2030
|
-
return `${
|
2069
|
+
function getReadableName(type) {
|
2070
|
+
if (type.priv.scopeName) {
|
2071
|
+
return `${type.shared.name}@${type.priv.scopeName}`;
|
2031
2072
|
}
|
2032
|
-
return
|
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
|
2116
|
-
return type.category === 9 /* TypeCategory.TypeVar */ && type.shared.
|
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.
|
2119
|
-
function
|
2120
|
-
return (type
|
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.
|
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
|
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.
|
2204
|
-
const type1TupleTypeArgs = type1.priv.
|
2205
|
-
const type2TupleTypeArgs = classType2.priv.
|
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.
|
2220
|
-
const type2TypeArgs = classType2.priv.
|
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.
|
2281
|
-
const param2Type = FunctionType.
|
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.
|
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.
|
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 (
|
2358
|
-
|
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.
|
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.
|
2707
|
+
if (!type.priv.typeArgs && !typeToAdd.priv.typeArgs) {
|
2665
2708
|
if (ClassType.isTypedDictNarrower(typeToAdd, type)) {
|
2666
2709
|
return;
|
2667
2710
|
}
|