@zzzen/pyright-internal 1.2.0-dev.20241013 → 1.2.0-dev.20241020
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/checker.js +3 -16
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/constructorTransform.js +3 -6
- package/dist/analyzer/constructorTransform.js.map +1 -1
- package/dist/analyzer/dataClasses.js +8 -1
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/importResolver.js +2 -10
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +84 -39
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +5 -3
- package/dist/analyzer/typeEvaluatorTypes.js +5 -3
- package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
- package/dist/analyzer/typeGuards.js +3 -3
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +5 -1
- package/dist/analyzer/typeUtils.js +18 -4
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typedDicts.js +41 -30
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.d.ts +3 -1
- package/dist/analyzer/types.js +3 -11
- package/dist/analyzer/types.js.map +1 -1
- package/dist/languageService/completionProvider.js +3 -1
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/localization/localize.d.ts +4 -0
- package/dist/localization/localize.js +2 -0
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.cs.json +1 -1
- package/dist/localization/package.nls.de.json +1 -1
- package/dist/localization/package.nls.en-us.json +7 -2
- package/dist/localization/package.nls.es.json +1 -1
- package/dist/localization/package.nls.fr.json +1 -1
- package/dist/localization/package.nls.it.json +1 -1
- package/dist/localization/package.nls.ja.json +1 -1
- package/dist/localization/package.nls.ko.json +1 -1
- package/dist/localization/package.nls.pl.json +1 -1
- package/dist/localization/package.nls.pt-br.json +1 -1
- package/dist/localization/package.nls.qps-ploc.json +1 -1
- package/dist/localization/package.nls.ru.json +1 -1
- package/dist/localization/package.nls.tr.json +1 -1
- package/dist/localization/package.nls.zh-cn.json +1 -1
- package/dist/localization/package.nls.zh-tw.json +1 -1
- package/dist/parser/tokenizer.d.ts +1 -0
- package/dist/parser/tokenizer.js +8 -0
- package/dist/parser/tokenizer.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +4 -0
- 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 +1 -1
- package/dist/tests/typeEvaluator8.test.js +8 -0
- package/dist/tests/typeEvaluator8.test.js.map +1 -1
- package/package.json +1 -1
@@ -158,6 +158,11 @@ const maxInferFunctionReturnRecursionCount = 12;
|
|
158
158
|
// it can increase the chance of false negatives for such recursive
|
159
159
|
// type aliases.
|
160
160
|
const maxRecursiveTypeAliasRecursionCount = 10;
|
161
|
+
// Normally a symbol can have only one type declaration, but there are
|
162
|
+
// cases where multiple are possible (e.g. a property with a setter
|
163
|
+
// and a deleter). In extreme cases, we need to limit the number of
|
164
|
+
// type declarations we consider to avoid excessive computation.
|
165
|
+
const maxTypedDeclsPerSymbol = 16;
|
161
166
|
// This switch enables a special debug mode that attempts to catch
|
162
167
|
// bugs due to inconsistent evaluation flags used when reading types
|
163
168
|
// from the type cache.
|
@@ -892,7 +897,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
892
897
|
if ((flags & 64 /* EvalFlags.NoTypeVarTuple */) === 0 && (0, types_1.isTypeVarTuple)(iterType) && !iterType.priv.isUnpacked) {
|
893
898
|
typeResult = { type: types_1.TypeVarType.cloneForUnpacked(iterType) };
|
894
899
|
}
|
895
|
-
else if ((flags &
|
900
|
+
else if ((flags & 4194304 /* EvalFlags.AllowUnpackedTuple */) !== 0 &&
|
896
901
|
(0, types_1.isInstantiableClass)(iterType) &&
|
897
902
|
types_1.ClassType.isBuiltIn(iterType, 'tuple')) {
|
898
903
|
typeResult = { type: types_1.ClassType.cloneForUnpacked(iterType) };
|
@@ -999,7 +1004,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
999
1004
|
let typeResult;
|
1000
1005
|
// In most cases, annotations within a string are not parsed by the interpreter.
|
1001
1006
|
// There are a few exceptions (e.g. the "bound" value for a TypeVar constructor).
|
1002
|
-
if ((flags &
|
1007
|
+
if ((flags & 16777216 /* EvalFlags.ParsesStringLiteral */) === 0) {
|
1003
1008
|
updatedFlags |= 524288 /* EvalFlags.NotParsed */;
|
1004
1009
|
}
|
1005
1010
|
updatedFlags &= ~1073741824 /* EvalFlags.TypeFormArg */;
|
@@ -2529,7 +2534,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
2529
2534
|
// Is this subtype a tuple?
|
2530
2535
|
const tupleType = (0, typeUtils_1.getSpecializedTupleType)(subtype);
|
2531
2536
|
if (tupleType && tupleType.priv.tupleTypeArgs) {
|
2532
|
-
const sourceEntryTypes = tupleType.priv.tupleTypeArgs.map((t) => (0, typeUtils_1.addConditionToType)(t.type, (0, typeUtils_1.getTypeCondition)(subtype),
|
2537
|
+
const sourceEntryTypes = tupleType.priv.tupleTypeArgs.map((t) => (0, typeUtils_1.addConditionToType)(t.type, (0, typeUtils_1.getTypeCondition)(subtype), { skipSelfCondition: true }));
|
2533
2538
|
const unboundedIndex = tupleType.priv.tupleTypeArgs.findIndex((t) => t.isUnbounded);
|
2534
2539
|
if (unboundedIndex >= 0) {
|
2535
2540
|
if (sourceEntryTypes.length < targetTypes.length) {
|
@@ -3538,7 +3543,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
3538
3543
|
// Walks up the parse tree to find a function, class, or type alias
|
3539
3544
|
// declaration that provides the context for a type variable.
|
3540
3545
|
function findScopedTypeVar(node, type) {
|
3541
|
-
var _a;
|
3546
|
+
var _a, _b;
|
3542
3547
|
let curNode = node;
|
3543
3548
|
let nestedClassCount = 0;
|
3544
3549
|
(0, debug_1.assert)(types_1.TypeBase.isInstantiable(type));
|
@@ -3605,7 +3610,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
3605
3610
|
// purposes of resolving type aliases?
|
3606
3611
|
if (leftType && (0, types_1.isTypeVar)(leftType) && leftType.shared.recursiveAlias) {
|
3607
3612
|
// Type alias statements cannot be used with old-style type variables.
|
3608
|
-
if (typeAliasNode && !type.shared.isTypeParamSyntax) {
|
3613
|
+
if (typeAliasNode && !type.shared.isTypeParamSyntax && !((_a = type.props) === null || _a === void 0 ? void 0 : _a.typeAliasInfo)) {
|
3609
3614
|
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typeParameterNotDeclared().format({
|
3610
3615
|
name: type.shared.name,
|
3611
3616
|
container: typeAliasNode.d.name.d.value,
|
@@ -3615,7 +3620,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
3615
3620
|
// If this is a TypeAliasType call, the recursive type parameters will already
|
3616
3621
|
// be populated, and we need to verify that the type parameter is in the
|
3617
3622
|
// list of allowed type parameters.
|
3618
|
-
const allowedTypeParams = (
|
3623
|
+
const allowedTypeParams = (_b = leftType.shared.recursiveAlias) === null || _b === void 0 ? void 0 : _b.typeParams;
|
3619
3624
|
if (allowedTypeParams) {
|
3620
3625
|
if (!allowedTypeParams.some((param) => param.shared.name === type.shared.name)) {
|
3621
3626
|
// Return the original type.
|
@@ -3835,8 +3840,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
3835
3840
|
}
|
3836
3841
|
if (typeResult) {
|
3837
3842
|
if (!typeResult.typeErrors) {
|
3838
|
-
type = (0, typeUtils_1.addConditionToType)(typeResult.type, (0, typeUtils_1.getTypeCondition)(baseType),
|
3839
|
-
|
3843
|
+
type = (0, typeUtils_1.addConditionToType)(typeResult.type, (0, typeUtils_1.getTypeCondition)(baseType), {
|
3844
|
+
skipSelfCondition: true,
|
3845
|
+
skipBoundTypeVars: true,
|
3846
|
+
});
|
3840
3847
|
}
|
3841
3848
|
else {
|
3842
3849
|
typeErrors = true;
|
@@ -3848,8 +3855,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
3848
3855
|
isIncomplete = true;
|
3849
3856
|
}
|
3850
3857
|
if (typeResult.narrowedTypeForSet) {
|
3851
|
-
narrowedTypeForSet = (0, typeUtils_1.addConditionToType)(typeResult.narrowedTypeForSet, (0, typeUtils_1.getTypeCondition)(baseType),
|
3852
|
-
/* skipSelfCondition */ true);
|
3858
|
+
narrowedTypeForSet = (0, typeUtils_1.addConditionToType)(typeResult.narrowedTypeForSet, (0, typeUtils_1.getTypeCondition)(baseType), { skipSelfCondition: true, skipBoundTypeVars: true });
|
3853
3859
|
}
|
3854
3860
|
if (typeResult.memberAccessDeprecationInfo) {
|
3855
3861
|
memberAccessDeprecationInfo = typeResult.memberAccessDeprecationInfo;
|
@@ -3939,7 +3945,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
3939
3945
|
(0, debug_1.assert)((0, types_1.isClassInstance)(subtype));
|
3940
3946
|
const typeResult = getTypeOfBoundMember(node.d.member, subtype, memberName, usage, diag);
|
3941
3947
|
if (typeResult && !typeResult.typeErrors) {
|
3942
|
-
type = (0, typeUtils_1.addConditionToType)(typeResult.type, (0, typeUtils_1.getTypeCondition)(baseType)
|
3948
|
+
type = (0, typeUtils_1.addConditionToType)(typeResult.type, (0, typeUtils_1.getTypeCondition)(baseType), {
|
3949
|
+
skipBoundTypeVars: true,
|
3950
|
+
});
|
3943
3951
|
if (typeResult.isIncomplete) {
|
3944
3952
|
isIncomplete = true;
|
3945
3953
|
}
|
@@ -5549,7 +5557,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
5549
5557
|
if (!(options === null || options === void 0 ? void 0 : options.isAnnotatedClass)) {
|
5550
5558
|
adjFlags |= 131072 /* EvalFlags.NoClassVar */ | 16 /* EvalFlags.NoFinal */;
|
5551
5559
|
}
|
5552
|
-
adjFlags |=
|
5560
|
+
adjFlags |= 4194304 /* EvalFlags.AllowUnpackedTuple */ | 134217728 /* EvalFlags.AllowConcatenate */;
|
5553
5561
|
}
|
5554
5562
|
// Create a local function that validates a single type argument.
|
5555
5563
|
const getTypeArgTypeResult = (expr, argIndex) => {
|
@@ -5931,6 +5939,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
5931
5939
|
if (!(0, types_1.isTypeSame)(assertedType, arg0Type, {
|
5932
5940
|
treatAnySameAsUnknown: true,
|
5933
5941
|
ignorePseudoGeneric: true,
|
5942
|
+
ignoreConditions: true,
|
5934
5943
|
})) {
|
5935
5944
|
const srcDestTypes = printSrcDestTypes(arg0TypeResult.type, assertedType, { expandTypeAlias: true });
|
5936
5945
|
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportAssertTypeFailure, localize_1.LocMessage.assertTypeTypeMismatch().format({
|
@@ -8411,7 +8420,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
8411
8420
|
eliminateUnsolvedInUnions,
|
8412
8421
|
},
|
8413
8422
|
});
|
8414
|
-
specializedReturnType = (0, typeUtils_1.addConditionToType)(specializedReturnType, typeCondition);
|
8423
|
+
specializedReturnType = (0, typeUtils_1.addConditionToType)(specializedReturnType, typeCondition, { skipBoundTypeVars: true });
|
8415
8424
|
// If the function includes a ParamSpec and the captured signature(s) includes
|
8416
8425
|
// generic types, we may need to apply those solved TypeVars.
|
8417
8426
|
if (paramSpecConstraints.length > 0) {
|
@@ -10967,13 +10976,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
10967
10976
|
isUsageLegal = true;
|
10968
10977
|
}
|
10969
10978
|
}
|
10970
|
-
if ((flags & 1048576 /* EvalFlags.AllowRequired */) !== 0) {
|
10971
|
-
isUsageLegal = true;
|
10972
|
-
}
|
10973
10979
|
let isReadOnly = typeArgs[0].isReadOnly;
|
10974
10980
|
let isRequired = typeArgs[0].isRequired;
|
10975
10981
|
let isNotRequired = typeArgs[0].isNotRequired;
|
10976
10982
|
if (classType.shared.name === 'ReadOnly') {
|
10983
|
+
if ((flags & 2097152 /* EvalFlags.AllowReadOnly */) !== 0) {
|
10984
|
+
isUsageLegal = true;
|
10985
|
+
}
|
10977
10986
|
// Nested ReadOnly are not allowed.
|
10978
10987
|
if (typeArgs[0].isReadOnly) {
|
10979
10988
|
isUsageLegal = false;
|
@@ -10981,6 +10990,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
10981
10990
|
isReadOnly = true;
|
10982
10991
|
}
|
10983
10992
|
else {
|
10993
|
+
if ((flags & 1048576 /* EvalFlags.AllowRequired */) !== 0) {
|
10994
|
+
isUsageLegal = true;
|
10995
|
+
}
|
10984
10996
|
// Nested Required/NotRequired are not allowed.
|
10985
10997
|
if (typeArgs[0].isRequired || typeArgs[0].isNotRequired) {
|
10986
10998
|
isUsageLegal = false;
|
@@ -11008,7 +11020,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
11008
11020
|
return classType;
|
11009
11021
|
}
|
11010
11022
|
const typeArgType = typeArgs[0].type;
|
11011
|
-
if ((flags &
|
11023
|
+
if ((flags & 4194304 /* EvalFlags.AllowUnpackedTuple */) !== 0) {
|
11012
11024
|
const unpackedType = applyUnpackToTupleLike(typeArgType);
|
11013
11025
|
if (unpackedType) {
|
11014
11026
|
return unpackedType;
|
@@ -11019,7 +11031,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
11019
11031
|
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.unpackExpectedTypeVarTuple(), errorNode);
|
11020
11032
|
return types_1.UnknownType.create();
|
11021
11033
|
}
|
11022
|
-
if ((flags &
|
11034
|
+
if ((flags & 8388608 /* EvalFlags.AllowUnpackedTypedDict */) !== 0) {
|
11023
11035
|
if ((0, types_1.isInstantiableClass)(typeArgType) && types_1.ClassType.isTypedDictClass(typeArgType)) {
|
11024
11036
|
return types_1.ClassType.cloneForUnpacked(typeArgType);
|
11025
11037
|
}
|
@@ -12143,6 +12155,21 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
12143
12155
|
if (AnalyzerNodeInfo.getFileInfo(node).diagnosticRuleSet.enableExperimentalFeatures) {
|
12144
12156
|
classType.shared.flags |=
|
12145
12157
|
8 /* ClassTypeFlags.TypedDictMarkedClosed */ | 16 /* ClassTypeFlags.TypedDictEffectivelyClosed */;
|
12158
|
+
if (classType.shared.typedDictExtraItemsExpr) {
|
12159
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typedDictExtraItemsClosed(), classType.shared.typedDictExtraItemsExpr);
|
12160
|
+
}
|
12161
|
+
}
|
12162
|
+
}
|
12163
|
+
}
|
12164
|
+
else if (arg.d.name.d.value === 'extra_items') {
|
12165
|
+
// This is an experimental feature because PEP 728 hasn't been accepted yet.
|
12166
|
+
if (AnalyzerNodeInfo.getFileInfo(node).diagnosticRuleSet.enableExperimentalFeatures) {
|
12167
|
+
// Record a reference to the expression but don't evaluate it yet.
|
12168
|
+
// It may refer to the class itself.
|
12169
|
+
classType.shared.typedDictExtraItemsExpr = arg.d.valueExpr;
|
12170
|
+
classType.shared.flags |= 16 /* ClassTypeFlags.TypedDictEffectivelyClosed */;
|
12171
|
+
if (types_1.ClassType.isTypedDictMarkedClosed(classType)) {
|
12172
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typedDictExtraItemsClosed(), classType.shared.typedDictExtraItemsExpr);
|
12146
12173
|
}
|
12147
12174
|
}
|
12148
12175
|
}
|
@@ -13355,9 +13382,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
13355
13382
|
if ((0, types_1.isParamSpec)(type) && type.priv.paramSpecAccess) {
|
13356
13383
|
return type;
|
13357
13384
|
}
|
13358
|
-
// Is this an unpacked TypedDict? If so, return
|
13385
|
+
// Is this an unpacked TypedDict? If so, return its packed version.
|
13359
13386
|
if ((0, types_1.isClassInstance)(type) && types_1.ClassType.isTypedDictClass(type) && type.priv.isUnpacked) {
|
13360
|
-
return type;
|
13387
|
+
return types_1.ClassType.cloneForPacked(type);
|
13361
13388
|
}
|
13362
13389
|
// Wrap the type in a dict with str keys.
|
13363
13390
|
const dictType = getBuiltInType(node, 'dict');
|
@@ -14971,7 +14998,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
14971
14998
|
flags |= 4 /* EvalFlags.ForwardRefs */;
|
14972
14999
|
}
|
14973
15000
|
else if (options === null || options === void 0 ? void 0 : options.parsesStringLiteral) {
|
14974
|
-
flags |=
|
15001
|
+
flags |= 16777216 /* EvalFlags.ParsesStringLiteral */;
|
14975
15002
|
}
|
14976
15003
|
if (!(options === null || options === void 0 ? void 0 : options.allowFinal)) {
|
14977
15004
|
flags |= 16 /* EvalFlags.NoFinal */;
|
@@ -14979,14 +15006,17 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
14979
15006
|
if (options === null || options === void 0 ? void 0 : options.allowRequired) {
|
14980
15007
|
flags |= 1048576 /* EvalFlags.AllowRequired */ | 256 /* EvalFlags.TypeExpression */;
|
14981
15008
|
}
|
15009
|
+
if (options === null || options === void 0 ? void 0 : options.allowReadOnly) {
|
15010
|
+
flags |= 2097152 /* EvalFlags.AllowReadOnly */ | 256 /* EvalFlags.TypeExpression */;
|
15011
|
+
}
|
14982
15012
|
if (options === null || options === void 0 ? void 0 : options.allowUnpackedTuple) {
|
14983
|
-
flags |=
|
15013
|
+
flags |= 4194304 /* EvalFlags.AllowUnpackedTuple */;
|
14984
15014
|
}
|
14985
15015
|
else {
|
14986
15016
|
flags |= 64 /* EvalFlags.NoTypeVarTuple */;
|
14987
15017
|
}
|
14988
15018
|
if (options === null || options === void 0 ? void 0 : options.allowUnpackedTypedDict) {
|
14989
|
-
flags |=
|
15019
|
+
flags |= 8388608 /* EvalFlags.AllowUnpackedTypedDict */;
|
14990
15020
|
}
|
14991
15021
|
if (!(options === null || options === void 0 ? void 0 : options.allowParamSpec)) {
|
14992
15022
|
flags |= 32 /* EvalFlags.NoParamSpec */;
|
@@ -15569,6 +15599,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
15569
15599
|
declaredType = (0, typeUtils_1.convertToInstance)(getTypeOfExpressionExpectingType(typeAnnotationNode, {
|
15570
15600
|
allowFinal: true,
|
15571
15601
|
allowRequired: true,
|
15602
|
+
allowReadOnly: true,
|
15572
15603
|
}).type);
|
15573
15604
|
}
|
15574
15605
|
else {
|
@@ -15581,6 +15612,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
15581
15612
|
allowClassVar: ParseTreeUtils.isClassVarAllowedForAssignmentTarget(declNode),
|
15582
15613
|
allowFinal: ParseTreeUtils.isFinalAllowedForAssignmentTarget(declNode),
|
15583
15614
|
allowRequired: ParseTreeUtils.isRequiredAllowedForAssignmentTarget(declNode),
|
15615
|
+
allowReadOnly: ParseTreeUtils.isRequiredAllowedForAssignmentTarget(declNode),
|
15584
15616
|
enforceClassTypeVarScope: declaration.isDefinedByMemberAccess,
|
15585
15617
|
});
|
15586
15618
|
}
|
@@ -16260,23 +16292,31 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16260
16292
|
// cases where a property symbol is redefined to add a setter, deleter,
|
16261
16293
|
// etc.
|
16262
16294
|
if (usageNode && typedDecls.length > 1) {
|
16263
|
-
|
16264
|
-
|
16265
|
-
|
16266
|
-
|
16267
|
-
|
16268
|
-
|
16269
|
-
|
16270
|
-
|
16295
|
+
if (typedDecls.length > maxTypedDeclsPerSymbol) {
|
16296
|
+
// If there are too many typed decls, don't bother filtering them
|
16297
|
+
// because this can be very expensive. Simply use the last one
|
16298
|
+
// in this case.
|
16299
|
+
typedDecls = [typedDecls[typedDecls.length - 1]];
|
16300
|
+
}
|
16301
|
+
else {
|
16302
|
+
const filteredTypedDecls = typedDecls.filter((decl) => {
|
16303
|
+
if (decl.type !== 8 /* DeclarationType.Alias */) {
|
16304
|
+
// Is the declaration in the same execution scope as the "usageNode" node?
|
16305
|
+
const usageScope = ParseTreeUtils.getExecutionScopeNode(usageNode);
|
16306
|
+
const declScope = ParseTreeUtils.getExecutionScopeNode(decl.node);
|
16307
|
+
if (usageScope === declScope) {
|
16308
|
+
if (!isFlowPathBetweenNodes(decl.node, usageNode, /* allowSelf */ false)) {
|
16309
|
+
return false;
|
16310
|
+
}
|
16271
16311
|
}
|
16272
16312
|
}
|
16313
|
+
return true;
|
16314
|
+
});
|
16315
|
+
if (filteredTypedDecls.length === 0) {
|
16316
|
+
return { type: types_1.UnboundType.create() };
|
16273
16317
|
}
|
16274
|
-
|
16275
|
-
});
|
16276
|
-
if (filteredTypedDecls.length === 0) {
|
16277
|
-
return { type: types_1.UnboundType.create() };
|
16318
|
+
typedDecls = filteredTypedDecls;
|
16278
16319
|
}
|
16279
|
-
typedDecls = filteredTypedDecls;
|
16280
16320
|
}
|
16281
16321
|
// Start with the last decl. If that's already being resolved,
|
16282
16322
|
// use the next-to-last decl, etc. This can happen when resolving
|
@@ -18407,6 +18447,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
18407
18447
|
}
|
18408
18448
|
}
|
18409
18449
|
else if (destParam.kind !== parameterUtils_1.ParamKind.Positional &&
|
18450
|
+
destParam.kind !== parameterUtils_1.ParamKind.ExpandedArgs &&
|
18410
18451
|
srcParam.kind === parameterUtils_1.ParamKind.Positional &&
|
18411
18452
|
srcParamDetails.kwargsIndex === undefined &&
|
18412
18453
|
!srcParamDetails.params.some((p) => p.kind === parameterUtils_1.ParamKind.Keyword &&
|
@@ -18495,7 +18536,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
18495
18536
|
if (!assignParam(destParamType, srcArgsType, paramIndex, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), constraints, flags, recursionCount)) {
|
18496
18537
|
canAssign = false;
|
18497
18538
|
}
|
18498
|
-
|
18539
|
+
const destParamKind = destParamDetails.params[paramIndex].kind;
|
18540
|
+
if (destParamKind !== parameterUtils_1.ParamKind.Positional &&
|
18541
|
+
destParamKind !== parameterUtils_1.ParamKind.ExpandedArgs &&
|
18499
18542
|
srcParamDetails.kwargsIndex === undefined) {
|
18500
18543
|
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocAddendum.namedParamMissingInSource().format({
|
18501
18544
|
name: (_g = destParamDetails.params[paramIndex].param.name) !== null && _g !== void 0 ? _g : '',
|
@@ -18569,7 +18612,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
18569
18612
|
if (index >= destParamDetails.firstKeywordOnlyIndex) {
|
18570
18613
|
if (param.param.name &&
|
18571
18614
|
param.param.category === 0 /* ParamCategory.Simple */ &&
|
18572
|
-
param.kind !== parameterUtils_1.ParamKind.Positional
|
18615
|
+
param.kind !== parameterUtils_1.ParamKind.Positional &&
|
18616
|
+
param.kind !== parameterUtils_1.ParamKind.ExpandedArgs) {
|
18573
18617
|
destParamMap.set(param.param.name, param);
|
18574
18618
|
}
|
18575
18619
|
}
|
@@ -19176,7 +19220,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
19176
19220
|
else if (i < overrideParamDetails.positionOnlyParamCount &&
|
19177
19221
|
i >= baseParamDetails.positionOnlyParamCount) {
|
19178
19222
|
if (!types_1.FunctionParam.isNameSynthesized(baseParam) &&
|
19179
|
-
baseParamDetails.params[i].kind !== parameterUtils_1.ParamKind.Positional
|
19223
|
+
baseParamDetails.params[i].kind !== parameterUtils_1.ParamKind.Positional &&
|
19224
|
+
baseParamDetails.params[i].kind !== parameterUtils_1.ParamKind.ExpandedArgs) {
|
19180
19225
|
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocAddendum.overrideParamNamePositionOnly().format({
|
19181
19226
|
index: i + 1,
|
19182
19227
|
baseName: baseParam.name || '*',
|