@zzzen/pyright-internal 1.2.0-dev.20240721 → 1.2.0-dev.20240728
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +115 -122
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.d.ts +2 -2
- package/dist/analyzer/codeFlowEngine.js +49 -42
- 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 +164 -204
- package/dist/analyzer/constraintSolver.js.map +1 -1
- package/dist/analyzer/constructorTransform.d.ts +2 -2
- package/dist/analyzer/constructorTransform.js +15 -15
- package/dist/analyzer/constructorTransform.js.map +1 -1
- package/dist/analyzer/constructors.d.ts +2 -2
- package/dist/analyzer/constructors.js +28 -33
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/dataClasses.d.ts +2 -2
- package/dist/analyzer/dataClasses.js +59 -36
- 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 +4 -4
- 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 +10 -10
- 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 +58 -58
- package/dist/analyzer/parameterUtils.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.d.ts +6 -6
- package/dist/analyzer/parseTreeUtils.js +22 -22
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/patternMatching.js +108 -89
- 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 +19 -19
- package/dist/analyzer/properties.js.map +1 -1
- package/dist/analyzer/protocols.js +14 -15
- 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/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 +1062 -1311
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +44 -40
- package/dist/analyzer/typeEvaluatorTypes.js +7 -1
- package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
- package/dist/analyzer/typeGuards.js +114 -85
- 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 +20 -18
- package/dist/analyzer/typeUtils.js +316 -321
- 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 +48 -52
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.d.ts +79 -57
- package/dist/analyzer/types.js +125 -113
- package/dist/analyzer/types.js.map +1 -1
- package/dist/commands/dumpFileDebugInfoCommand.js +11 -11
- 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 +3 -3
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/languageService/referencesProvider.js +2 -2
- 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 +5 -0
- package/dist/localization/localize.js +6 -0
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.cs.json +5 -1
- package/dist/localization/package.nls.de.json +5 -1
- package/dist/localization/package.nls.en-us.json +5 -0
- package/dist/localization/package.nls.es.json +5 -1
- package/dist/localization/package.nls.fr.json +5 -1
- package/dist/localization/package.nls.it.json +5 -1
- package/dist/localization/package.nls.ja.json +5 -1
- package/dist/localization/package.nls.ko.json +5 -1
- package/dist/localization/package.nls.pl.json +5 -1
- package/dist/localization/package.nls.pt-br.json +5 -1
- package/dist/localization/package.nls.qps-ploc.json +5 -1
- package/dist/localization/package.nls.ru.json +5 -1
- package/dist/localization/package.nls.tr.json +5 -1
- package/dist/localization/package.nls.zh-cn.json +5 -1
- package/dist/localization/package.nls.zh-tw.json +5 -1
- package/dist/parser/parseNodes.d.ts +9 -9
- package/dist/parser/parseNodes.js +20 -20
- package/dist/parser/parseNodes.js.map +1 -1
- package/dist/parser/parser.js +30 -30
- package/dist/parser/parser.js.map +1 -1
- package/dist/tests/checker.test.js +2 -2
- 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/typeEvaluator3.test.js +1 -1
- package/dist/tests/typeEvaluator4.test.js +9 -1
- 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 +72 -60
- package/dist/tests/typeEvaluator6.test.js.map +1 -1
- package/dist/tests/typeEvaluator7.test.js +2 -2
- 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,14 +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
|
-
FunctionType.addHigherOrderTypeVarScopeIds(newFunction,
|
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; }));
|
1254
1252
|
return newFunction;
|
1255
1253
|
}
|
1256
1254
|
FunctionType.cloneWithNewTypeVarScopeId = cloneWithNewTypeVarScopeId;
|
@@ -1281,12 +1279,11 @@ var FunctionType;
|
|
1281
1279
|
}
|
1282
1280
|
const argsParam = type.shared.parameters[paramCount - 2];
|
1283
1281
|
const kwargsParam = type.shared.parameters[paramCount - 1];
|
1284
|
-
if (argsParam.category !== 1 /*
|
1285
|
-
kwargsParam.category !== 2 /* ParameterCategory.KwargsDict */) {
|
1282
|
+
if (argsParam.category !== 1 /* ParamCategory.ArgsList */ || kwargsParam.category !== 2 /* ParamCategory.KwargsDict */) {
|
1286
1283
|
return type;
|
1287
1284
|
}
|
1288
|
-
const argsType = FunctionType.
|
1289
|
-
const kwargsType = FunctionType.
|
1285
|
+
const argsType = FunctionType.getEffectiveParamType(type, paramCount - 2);
|
1286
|
+
const kwargsType = FunctionType.getEffectiveParamType(type, paramCount - 1);
|
1290
1287
|
if (!isParamSpec(argsType) || !isParamSpec(kwargsType) || !isTypeSame(argsType, kwargsType)) {
|
1291
1288
|
return type;
|
1292
1289
|
}
|
@@ -1327,11 +1324,11 @@ var FunctionType;
|
|
1327
1324
|
}
|
1328
1325
|
const secondLastParam = params[params.length - 2];
|
1329
1326
|
const lastParam = params[params.length - 1];
|
1330
|
-
if (secondLastParam.category === 1 /*
|
1331
|
-
|
1327
|
+
if (secondLastParam.category === 1 /* ParamCategory.ArgsList */ &&
|
1328
|
+
isParamSpec(secondLastParam.type) &&
|
1332
1329
|
secondLastParam.type.priv.paramSpecAccess === 'args' &&
|
1333
|
-
lastParam.category === 2 /*
|
1334
|
-
|
1330
|
+
lastParam.category === 2 /* ParamCategory.KwargsDict */ &&
|
1331
|
+
isParamSpec(lastParam.type) &&
|
1335
1332
|
lastParam.type.priv.paramSpecAccess === 'kwargs') {
|
1336
1333
|
return TypeVarType.cloneForParamSpecAccess(secondLastParam.type, /* access */ undefined);
|
1337
1334
|
}
|
@@ -1339,16 +1336,16 @@ var FunctionType;
|
|
1339
1336
|
}
|
1340
1337
|
FunctionType.getParamSpecFromArgsKwargs = getParamSpecFromArgsKwargs;
|
1341
1338
|
function addParamSpecVariadics(type, paramSpec) {
|
1342
|
-
FunctionType.
|
1343
|
-
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'));
|
1344
1341
|
}
|
1345
1342
|
FunctionType.addParamSpecVariadics = addParamSpecVariadics;
|
1346
|
-
function
|
1347
|
-
|
1348
|
-
FunctionType.
|
1343
|
+
function addDefaultParams(type, useUnknown = false) {
|
1344
|
+
getDefaultParams(useUnknown).forEach((param) => {
|
1345
|
+
FunctionType.addParam(type, param);
|
1349
1346
|
});
|
1350
1347
|
}
|
1351
|
-
FunctionType.
|
1348
|
+
FunctionType.addDefaultParams = addDefaultParams;
|
1352
1349
|
function addHigherOrderTypeVarScopeIds(functionType, scopeIds) {
|
1353
1350
|
if (!scopeIds) {
|
1354
1351
|
return;
|
@@ -1370,15 +1367,15 @@ var FunctionType;
|
|
1370
1367
|
});
|
1371
1368
|
}
|
1372
1369
|
FunctionType.addHigherOrderTypeVarScopeIds = addHigherOrderTypeVarScopeIds;
|
1373
|
-
function
|
1370
|
+
function getDefaultParams(useUnknown = false) {
|
1374
1371
|
return [
|
1375
|
-
FunctionParam.create(1 /*
|
1376
|
-
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'),
|
1377
1374
|
];
|
1378
1375
|
}
|
1379
|
-
FunctionType.
|
1376
|
+
FunctionType.getDefaultParams = getDefaultParams;
|
1380
1377
|
// Indicates whether the input signature consists of (*args: Any, **kwargs: Any).
|
1381
|
-
function
|
1378
|
+
function hasDefaultParams(functionType) {
|
1382
1379
|
let sawArgs = false;
|
1383
1380
|
let sawKwargs = false;
|
1384
1381
|
for (let i = 0; i < functionType.shared.parameters.length; i++) {
|
@@ -1387,22 +1384,22 @@ var FunctionType;
|
|
1387
1384
|
if (!param.name) {
|
1388
1385
|
continue;
|
1389
1386
|
}
|
1390
|
-
if (param.category === 0 /*
|
1387
|
+
if (param.category === 0 /* ParamCategory.Simple */) {
|
1391
1388
|
return false;
|
1392
1389
|
}
|
1393
|
-
else if (param.category === 1 /*
|
1390
|
+
else if (param.category === 1 /* ParamCategory.ArgsList */) {
|
1394
1391
|
sawArgs = true;
|
1395
1392
|
}
|
1396
|
-
else if (param.category === 2 /*
|
1393
|
+
else if (param.category === 2 /* ParamCategory.KwargsDict */) {
|
1397
1394
|
sawKwargs = true;
|
1398
1395
|
}
|
1399
|
-
if (!isAnyOrUnknown(FunctionType.
|
1396
|
+
if (!isAnyOrUnknown(FunctionType.getEffectiveParamType(functionType, i))) {
|
1400
1397
|
return false;
|
1401
1398
|
}
|
1402
1399
|
}
|
1403
1400
|
return sawArgs && sawKwargs;
|
1404
1401
|
}
|
1405
|
-
FunctionType.
|
1402
|
+
FunctionType.hasDefaultParams = hasDefaultParams;
|
1406
1403
|
function isInstanceMethod(type) {
|
1407
1404
|
return ((type.shared.flags &
|
1408
1405
|
(1 /* FunctionTypeFlags.ConstructorMethod */ |
|
@@ -1443,10 +1440,10 @@ var FunctionType;
|
|
1443
1440
|
return (type.shared.flags & 256 /* FunctionTypeFlags.Overloaded */) !== 0;
|
1444
1441
|
}
|
1445
1442
|
FunctionType.isOverloaded = isOverloaded;
|
1446
|
-
function
|
1443
|
+
function isDefaultParamCheckDisabled(type) {
|
1447
1444
|
return (type.shared.flags & 32 /* FunctionTypeFlags.DisableDefaultChecks */) !== 0;
|
1448
1445
|
}
|
1449
|
-
FunctionType.
|
1446
|
+
FunctionType.isDefaultParamCheckDisabled = isDefaultParamCheckDisabled;
|
1450
1447
|
function isAsync(type) {
|
1451
1448
|
return (type.shared.flags & 512 /* FunctionTypeFlags.Async */) !== 0;
|
1452
1449
|
}
|
@@ -1494,15 +1491,15 @@ var FunctionType;
|
|
1494
1491
|
return true;
|
1495
1492
|
}
|
1496
1493
|
FunctionType.isBuiltIn = isBuiltIn;
|
1497
|
-
function
|
1494
|
+
function getEffectiveParamType(type, index) {
|
1498
1495
|
(0, debug_1.assert)(index < type.shared.parameters.length, 'Parameter types array overflow');
|
1499
1496
|
if (type.priv.specializedTypes && index < type.priv.specializedTypes.parameterTypes.length) {
|
1500
1497
|
return type.priv.specializedTypes.parameterTypes[index];
|
1501
1498
|
}
|
1502
1499
|
return type.shared.parameters[index].type;
|
1503
1500
|
}
|
1504
|
-
FunctionType.
|
1505
|
-
function
|
1501
|
+
FunctionType.getEffectiveParamType = getEffectiveParamType;
|
1502
|
+
function getEffectiveParamDefaultArgType(type, index) {
|
1506
1503
|
var _a;
|
1507
1504
|
(0, debug_1.assert)(index < type.shared.parameters.length, 'Parameter types array overflow');
|
1508
1505
|
if (((_a = type.priv.specializedTypes) === null || _a === void 0 ? void 0 : _a.parameterDefaultArgs) &&
|
@@ -1514,22 +1511,22 @@ var FunctionType;
|
|
1514
1511
|
}
|
1515
1512
|
return type.shared.parameters[index].defaultType;
|
1516
1513
|
}
|
1517
|
-
FunctionType.
|
1518
|
-
function
|
1514
|
+
FunctionType.getEffectiveParamDefaultArgType = getEffectiveParamDefaultArgType;
|
1515
|
+
function addParam(type, param) {
|
1519
1516
|
type.shared.parameters.push(param);
|
1520
1517
|
if (type.priv.specializedTypes) {
|
1521
1518
|
type.priv.specializedTypes.parameterTypes.push(param.type);
|
1522
1519
|
}
|
1523
1520
|
}
|
1524
|
-
FunctionType.
|
1525
|
-
function
|
1526
|
-
|
1521
|
+
FunctionType.addParam = addParam;
|
1522
|
+
function addPositionOnlyParamSeparator(type) {
|
1523
|
+
addParam(type, FunctionParam.create(0 /* ParamCategory.Simple */, AnyType.create()));
|
1527
1524
|
}
|
1528
|
-
FunctionType.
|
1529
|
-
function
|
1530
|
-
|
1525
|
+
FunctionType.addPositionOnlyParamSeparator = addPositionOnlyParamSeparator;
|
1526
|
+
function addKeywordOnlyParamSeparator(type) {
|
1527
|
+
addParam(type, FunctionParam.create(1 /* ParamCategory.ArgsList */, AnyType.create()));
|
1531
1528
|
}
|
1532
|
-
FunctionType.
|
1529
|
+
FunctionType.addKeywordOnlyParamSeparator = addKeywordOnlyParamSeparator;
|
1533
1530
|
function getEffectiveReturnType(type, includeInferred = true) {
|
1534
1531
|
var _a;
|
1535
1532
|
if ((_a = type.priv.specializedTypes) === null || _a === void 0 ? void 0 : _a.returnType) {
|
@@ -1856,20 +1853,36 @@ var Variance;
|
|
1856
1853
|
Variance[Variance["Covariant"] = 3] = "Covariant";
|
1857
1854
|
Variance[Variance["Contravariant"] = 4] = "Contravariant";
|
1858
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 = {}));
|
1859
1862
|
var TypeVarScopeType;
|
1860
1863
|
(function (TypeVarScopeType) {
|
1861
1864
|
TypeVarScopeType[TypeVarScopeType["Class"] = 0] = "Class";
|
1862
1865
|
TypeVarScopeType[TypeVarScopeType["Function"] = 1] = "Function";
|
1863
1866
|
TypeVarScopeType[TypeVarScopeType["TypeAlias"] = 2] = "TypeAlias";
|
1864
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 = {}));
|
1865
1878
|
var TypeVarType;
|
1866
1879
|
(function (TypeVarType) {
|
1867
|
-
function createInstance(name) {
|
1868
|
-
return create(name,
|
1880
|
+
function createInstance(name, kind = TypeVarKind.TypeVar) {
|
1881
|
+
return create(name, kind, 2 /* TypeFlags.Instance */);
|
1869
1882
|
}
|
1870
1883
|
TypeVarType.createInstance = createInstance;
|
1871
|
-
function createInstantiable(name,
|
1872
|
-
return create(name,
|
1884
|
+
function createInstantiable(name, kind = TypeVarKind.TypeVar) {
|
1885
|
+
return create(name, kind, 1 /* TypeFlags.Instantiable */);
|
1873
1886
|
}
|
1874
1887
|
TypeVarType.createInstantiable = createInstantiable;
|
1875
1888
|
function cloneAsInstance(type) {
|
@@ -1920,7 +1933,6 @@ var TypeVarType;
|
|
1920
1933
|
}
|
1921
1934
|
TypeVarType.cloneForScopeId = cloneForScopeId;
|
1922
1935
|
function cloneForUnpacked(type, isInUnion = false) {
|
1923
|
-
(0, debug_1.assert)(type.shared.isVariadic);
|
1924
1936
|
const newInstance = TypeBase.cloneType(type);
|
1925
1937
|
newInstance.priv.isVariadicUnpacked = true;
|
1926
1938
|
newInstance.priv.isVariadicInUnion = isInUnion;
|
@@ -1931,7 +1943,6 @@ var TypeVarType;
|
|
1931
1943
|
}
|
1932
1944
|
TypeVarType.cloneForUnpacked = cloneForUnpacked;
|
1933
1945
|
function cloneForPacked(type) {
|
1934
|
-
(0, debug_1.assert)(type.shared.isVariadic);
|
1935
1946
|
const newInstance = TypeBase.cloneType(type);
|
1936
1947
|
newInstance.priv.isVariadicUnpacked = false;
|
1937
1948
|
newInstance.priv.isVariadicInUnion = false;
|
@@ -1945,7 +1956,7 @@ var TypeVarType;
|
|
1945
1956
|
// and no bound or constraints. ParamSpecs and variadics are left
|
1946
1957
|
// unmodified. So are auto-variant type variables.
|
1947
1958
|
function cloneAsInvariant(type) {
|
1948
|
-
if (type
|
1959
|
+
if (isParamSpec(type) || isTypeVarTuple(type)) {
|
1949
1960
|
return type;
|
1950
1961
|
}
|
1951
1962
|
if (type.shared.declaredVariance === 0 /* Variance.Auto */) {
|
@@ -2021,20 +2032,19 @@ var TypeVarType;
|
|
2021
2032
|
return !!type.priv.externalTypeVar;
|
2022
2033
|
}
|
2023
2034
|
TypeVarType.hasInternalScopeId = hasInternalScopeId;
|
2024
|
-
function create(name,
|
2035
|
+
function create(name, kind, typeFlags) {
|
2025
2036
|
const newTypeVarType = {
|
2026
2037
|
category: 9 /* TypeCategory.TypeVar */,
|
2027
2038
|
flags: typeFlags,
|
2028
2039
|
props: undefined,
|
2029
2040
|
cached: undefined,
|
2030
2041
|
shared: {
|
2042
|
+
kind,
|
2031
2043
|
name,
|
2032
2044
|
constraints: [],
|
2033
2045
|
boundType: undefined,
|
2034
2046
|
isDefaultExplicit: false,
|
2035
2047
|
defaultType: UnknownType.create(),
|
2036
|
-
isParamSpec,
|
2037
|
-
isVariadic: false,
|
2038
2048
|
declaredVariance: 2 /* Variance.Invariant */,
|
2039
2049
|
isSynthesized: false,
|
2040
2050
|
isSynthesizedSelf: false,
|
@@ -2143,17 +2153,18 @@ function isTypeVar(type) {
|
|
2143
2153
|
return type.category === 9 /* TypeCategory.TypeVar */;
|
2144
2154
|
}
|
2145
2155
|
exports.isTypeVar = isTypeVar;
|
2146
|
-
function
|
2147
|
-
return type.category === 9 /* TypeCategory.TypeVar */ && type.shared.
|
2156
|
+
function isParamSpec(type) {
|
2157
|
+
return type.category === 9 /* TypeCategory.TypeVar */ && type.shared.kind === TypeVarKind.ParamSpec;
|
2148
2158
|
}
|
2149
|
-
exports.
|
2150
|
-
function
|
2151
|
-
return
|
2152
|
-
type.shared.isVariadic &&
|
2153
|
-
!!type.priv.isVariadicUnpacked &&
|
2154
|
-
!type.priv.isVariadicInUnion);
|
2159
|
+
exports.isParamSpec = isParamSpec;
|
2160
|
+
function isTypeVarTuple(type) {
|
2161
|
+
return type.category === 9 /* TypeCategory.TypeVar */ && type.shared.kind === TypeVarKind.TypeVarTuple;
|
2155
2162
|
}
|
2156
|
-
exports.
|
2163
|
+
exports.isTypeVarTuple = isTypeVarTuple;
|
2164
|
+
function isUnpackedTypeVarTuple(type) {
|
2165
|
+
return isTypeVarTuple(type) && !!type.priv.isVariadicUnpacked && !type.priv.isVariadicInUnion;
|
2166
|
+
}
|
2167
|
+
exports.isUnpackedTypeVarTuple = isUnpackedTypeVarTuple;
|
2157
2168
|
function isUnpackedClass(type) {
|
2158
2169
|
if (!isClass(type) || !type.priv.isUnpacked) {
|
2159
2170
|
return false;
|
@@ -2162,13 +2173,9 @@ function isUnpackedClass(type) {
|
|
2162
2173
|
}
|
2163
2174
|
exports.isUnpackedClass = isUnpackedClass;
|
2164
2175
|
function isUnpacked(type) {
|
2165
|
-
return
|
2176
|
+
return isUnpackedTypeVarTuple(type) || isUnpackedClass(type);
|
2166
2177
|
}
|
2167
2178
|
exports.isUnpacked = isUnpacked;
|
2168
|
-
function isParamSpec(type) {
|
2169
|
-
return type.category === 9 /* TypeCategory.TypeVar */ && type.shared.isParamSpec;
|
2170
|
-
}
|
2171
|
-
exports.isParamSpec = isParamSpec;
|
2172
2179
|
function isFunction(type) {
|
2173
2180
|
return type.category === 4 /* TypeCategory.Function */;
|
2174
2181
|
}
|
@@ -2231,9 +2238,9 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
|
|
2231
2238
|
}
|
2232
2239
|
if (!options.ignorePseudoGeneric || !ClassType.isPseudoGenericClass(type1)) {
|
2233
2240
|
// Make sure the type args match.
|
2234
|
-
if (type1.priv.
|
2235
|
-
const type1TupleTypeArgs = type1.priv.
|
2236
|
-
const type2TupleTypeArgs = classType2.priv.
|
2241
|
+
if (type1.priv.tupleTypeArgs && classType2.priv.tupleTypeArgs) {
|
2242
|
+
const type1TupleTypeArgs = type1.priv.tupleTypeArgs || [];
|
2243
|
+
const type2TupleTypeArgs = classType2.priv.tupleTypeArgs || [];
|
2237
2244
|
if (type1TupleTypeArgs.length !== type2TupleTypeArgs.length) {
|
2238
2245
|
return false;
|
2239
2246
|
}
|
@@ -2247,8 +2254,8 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
|
|
2247
2254
|
}
|
2248
2255
|
}
|
2249
2256
|
else {
|
2250
|
-
const type1TypeArgs = type1.priv.
|
2251
|
-
const type2TypeArgs = classType2.priv.
|
2257
|
+
const type1TypeArgs = type1.priv.typeArgs || [];
|
2258
|
+
const type2TypeArgs = classType2.priv.typeArgs || [];
|
2252
2259
|
const typeArgCount = Math.max(type1TypeArgs.length, type2TypeArgs.length);
|
2253
2260
|
for (let i = 0; i < typeArgCount; i++) {
|
2254
2261
|
// Assume that missing type args are "Unknown".
|
@@ -2308,8 +2315,8 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
|
|
2308
2315
|
else if (isKeywordOnlySeparator(param1) && isKeywordOnlySeparator(param2)) {
|
2309
2316
|
continue;
|
2310
2317
|
}
|
2311
|
-
const param1Type = FunctionType.
|
2312
|
-
const param2Type = FunctionType.
|
2318
|
+
const param1Type = FunctionType.getEffectiveParamType(type1, i);
|
2319
|
+
const param2Type = FunctionType.getEffectiveParamType(functionType2, i);
|
2313
2320
|
if (!isTypeSame(param1Type, param2Type, { ...options, ignoreTypeFlags: false }, recursionCount)) {
|
2314
2321
|
return false;
|
2315
2322
|
}
|
@@ -2373,8 +2380,8 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
|
|
2373
2380
|
// Handle the case where this is a generic recursive type alias. Make
|
2374
2381
|
// sure that the type argument types match.
|
2375
2382
|
if (type1.shared.recursiveAlias && type2TypeVar.shared.recursiveAlias) {
|
2376
|
-
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.
|
2377
|
-
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) || [];
|
2378
2385
|
const typeArgCount = Math.max(type1TypeArgs.length, type2TypeArgs.length);
|
2379
2386
|
for (let i = 0; i < typeArgCount; i++) {
|
2380
2387
|
// Assume that missing type args are "Any".
|
@@ -2385,15 +2392,21 @@ function isTypeSame(type1, type2, options = {}, recursionCount = 0) {
|
|
2385
2392
|
}
|
2386
2393
|
}
|
2387
2394
|
}
|
2388
|
-
if (
|
2389
|
-
|
2395
|
+
if (isTypeVarTuple(type1) && isTypeVarTuple(type2TypeVar)) {
|
2396
|
+
if (!type1.priv.isVariadicInUnion !== !type2TypeVar.priv.isVariadicInUnion) {
|
2397
|
+
return false;
|
2398
|
+
}
|
2390
2399
|
}
|
2391
2400
|
if (type1.shared === type2TypeVar.shared) {
|
2392
2401
|
return true;
|
2393
2402
|
}
|
2403
|
+
if (isParamSpec(type1) !== isParamSpec(type2TypeVar)) {
|
2404
|
+
return false;
|
2405
|
+
}
|
2406
|
+
if (isTypeVarTuple(type1) !== isTypeVarTuple(type2TypeVar)) {
|
2407
|
+
return false;
|
2408
|
+
}
|
2394
2409
|
if (type1.shared.name !== type2TypeVar.shared.name ||
|
2395
|
-
type1.shared.isParamSpec !== type2TypeVar.shared.isParamSpec ||
|
2396
|
-
type1.shared.isVariadic !== type2TypeVar.shared.isVariadic ||
|
2397
2410
|
type1.shared.isSynthesized !== type2TypeVar.shared.isSynthesized ||
|
2398
2411
|
type1.shared.declaredVariance !== type2TypeVar.shared.declaredVariance ||
|
2399
2412
|
type1.priv.scopeId !== type2TypeVar.priv.scopeId) {
|
@@ -2663,8 +2676,7 @@ function _addTypeIfUnique(unionType, typeToAdd, elideRedundantLiterals) {
|
|
2663
2676
|
// parameterized with its own class) ad infinitum.
|
2664
2677
|
if (isPseudoGeneric) {
|
2665
2678
|
if (isTypeSame(type, typeToAdd, { ignorePseudoGeneric: true })) {
|
2666
|
-
unionType.priv.subtypes[i] = ClassType.
|
2667
|
-
/* isTypeArgumentExplicit */ true);
|
2679
|
+
unionType.priv.subtypes[i] = ClassType.specialize(typeToAdd, typeToAdd.shared.typeParams.map(() => UnknownType.create()));
|
2668
2680
|
return;
|
2669
2681
|
}
|
2670
2682
|
}
|
@@ -2692,7 +2704,7 @@ function _addTypeIfUnique(unionType, typeToAdd, elideRedundantLiterals) {
|
|
2692
2704
|
// existing type, see if one of them is a proper subset of the other.
|
2693
2705
|
if (ClassType.isTypedDictClass(type) && ClassType.isSameGenericClass(type, typeToAdd)) {
|
2694
2706
|
// Do not proceed if the TypedDicts are generic and have different type arguments.
|
2695
|
-
if (!type.priv.
|
2707
|
+
if (!type.priv.typeArgs && !typeToAdd.priv.typeArgs) {
|
2696
2708
|
if (ClassType.isTypedDictNarrower(typeToAdd, type)) {
|
2697
2709
|
return;
|
2698
2710
|
}
|