@zzzen/pyright-internal 1.2.0-dev.20240728 → 1.2.0-dev.20240804
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/binder.js +7 -4
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.d.ts +2 -1
- package/dist/analyzer/checker.js +135 -83
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.js +4 -4
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/constraintSolution.d.ts +21 -0
- package/dist/analyzer/constraintSolution.js +71 -0
- package/dist/analyzer/constraintSolution.js.map +1 -0
- package/dist/analyzer/constraintSolver.d.ts +9 -5
- package/dist/analyzer/constraintSolver.js +420 -322
- package/dist/analyzer/constraintSolver.js.map +1 -1
- package/dist/analyzer/constraintTracker.d.ts +44 -0
- package/dist/analyzer/constraintTracker.js +230 -0
- package/dist/analyzer/constraintTracker.js.map +1 -0
- package/dist/analyzer/constructorTransform.js +15 -15
- package/dist/analyzer/constructorTransform.js.map +1 -1
- package/dist/analyzer/constructors.d.ts +1 -1
- package/dist/analyzer/constructors.js +59 -38
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/dataClasses.js +35 -32
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/decorators.js +1 -1
- package/dist/analyzer/decorators.js.map +1 -1
- package/dist/analyzer/functionTransform.js +1 -1
- package/dist/analyzer/functionTransform.js.map +1 -1
- package/dist/analyzer/operations.d.ts +1 -2
- package/dist/analyzer/operations.js +95 -72
- package/dist/analyzer/operations.js.map +1 -1
- package/dist/analyzer/packageTypeVerifier.js +8 -4
- package/dist/analyzer/packageTypeVerifier.js.map +1 -1
- package/dist/analyzer/parameterUtils.d.ts +3 -3
- package/dist/analyzer/parameterUtils.js +19 -21
- package/dist/analyzer/parameterUtils.js.map +1 -1
- package/dist/analyzer/patternMatching.js +21 -19
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/properties.d.ts +3 -2
- package/dist/analyzer/properties.js +11 -11
- package/dist/analyzer/properties.js.map +1 -1
- package/dist/analyzer/protocols.d.ts +3 -3
- package/dist/analyzer/protocols.js +50 -48
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/tuples.d.ts +2 -2
- package/dist/analyzer/tuples.js +10 -9
- package/dist/analyzer/tuples.js.map +1 -1
- package/dist/analyzer/typeComplexity.js +12 -4
- package/dist/analyzer/typeComplexity.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +806 -778
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +28 -8
- package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
- package/dist/analyzer/typeGuards.js +46 -39
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typePrinter.js +17 -15
- package/dist/analyzer/typePrinter.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +32 -30
- package/dist/analyzer/typeUtils.js +331 -563
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typeWalker.js +1 -1
- package/dist/analyzer/typeWalker.js.map +1 -1
- package/dist/analyzer/typedDicts.d.ts +2 -2
- package/dist/analyzer/typedDicts.js +25 -25
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.d.ts +24 -21
- package/dist/analyzer/types.js +110 -113
- package/dist/analyzer/types.js.map +1 -1
- package/dist/languageServerBase.d.ts +2 -2
- package/dist/languageServerBase.js +5 -2
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/completionProvider.js +2 -2
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/tests/checker.test.js +10 -2
- package/dist/tests/checker.test.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +1 -1
- package/dist/tests/typeEvaluator2.test.js +12 -0
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +4 -0
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +1 -1
- package/dist/tests/typeEvaluator5.test.js +1 -1
- package/dist/tests/typeEvaluator7.test.js +4 -0
- package/dist/tests/typeEvaluator7.test.js.map +1 -1
- package/dist/tests/typeEvaluator8.test.js +4 -0
- package/dist/tests/typeEvaluator8.test.js.map +1 -1
- package/package.json +1 -1
- package/dist/analyzer/typeVarContext.d.ts +0 -48
- package/dist/analyzer/typeVarContext.js +0 -288
- package/dist/analyzer/typeVarContext.js.map +0 -1
package/dist/analyzer/checker.js
CHANGED
@@ -50,6 +50,7 @@ const localize_1 = require("../localization/localize");
|
|
50
50
|
const parseNodes_1 = require("../parser/parseNodes");
|
51
51
|
const stringTokenUtils_1 = require("../parser/stringTokenUtils");
|
52
52
|
const AnalyzerNodeInfo = __importStar(require("./analyzerNodeInfo"));
|
53
|
+
const constraintTracker_1 = require("./constraintTracker");
|
53
54
|
const constructors_1 = require("./constructors");
|
54
55
|
const dataClasses_1 = require("./dataClasses");
|
55
56
|
const declaration_1 = require("./declaration");
|
@@ -69,13 +70,12 @@ const sourceMapper_1 = require("./sourceMapper");
|
|
69
70
|
const staticExpressions_1 = require("./staticExpressions");
|
70
71
|
const SymbolNameUtils = __importStar(require("./symbolNameUtils"));
|
71
72
|
const symbolUtils_1 = require("./symbolUtils");
|
73
|
+
const typedDicts_1 = require("./typedDicts");
|
72
74
|
const typeEvaluator_1 = require("./typeEvaluator");
|
73
75
|
const typeEvaluatorTypes_1 = require("./typeEvaluatorTypes");
|
74
76
|
const typeGuards_1 = require("./typeGuards");
|
75
|
-
const typeUtils_1 = require("./typeUtils");
|
76
|
-
const typeVarContext_1 = require("./typeVarContext");
|
77
|
-
const typedDicts_1 = require("./typedDicts");
|
78
77
|
const types_1 = require("./types");
|
78
|
+
const typeUtils_1 = require("./typeUtils");
|
79
79
|
// When enabled, this debug flag causes the code complexity of
|
80
80
|
// functions to be emitted.
|
81
81
|
const isPrintCodeComplexityEnabled = false;
|
@@ -248,14 +248,15 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
248
248
|
}
|
249
249
|
// Allow unknown and missing param types if the param is named '_'.
|
250
250
|
if (param.d.name && param.d.name.d.value !== '_') {
|
251
|
-
const
|
252
|
-
if (
|
253
|
-
const
|
251
|
+
const paramIndex = functionTypeResult.functionType.shared.parameters.findIndex((p) => { var _a; return p.name === ((_a = param.d.name) === null || _a === void 0 ? void 0 : _a.d.value); });
|
252
|
+
if (paramIndex >= 0) {
|
253
|
+
const functionTypeParam = functionTypeResult.functionType.shared.parameters[paramIndex];
|
254
|
+
const paramType = types_1.FunctionType.getParamType(functionTypeResult.functionType, paramIndex);
|
254
255
|
if (this._fileInfo.diagnosticRuleSet.reportUnknownParameterType !== 'none') {
|
255
256
|
if ((0, types_1.isUnknown)(paramType) ||
|
256
257
|
((0, types_1.isTypeVar)(paramType) &&
|
257
258
|
paramType.shared.isSynthesized &&
|
258
|
-
!
|
259
|
+
!types_1.TypeVarType.isSelf(paramType))) {
|
259
260
|
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnknownParameterType, localize_1.LocMessage.paramTypeUnknown().format({ paramName: param.d.name.d.value }), param.d.name);
|
260
261
|
}
|
261
262
|
else if ((0, typeUtils_1.isPartlyUnknown)(paramType)) {
|
@@ -274,7 +275,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
274
275
|
}
|
275
276
|
else {
|
276
277
|
// See if this is a "self" and "cls" parameter. They are exempt from this rule.
|
277
|
-
if ((0, types_1.isTypeVar)(paramType) &&
|
278
|
+
if ((0, types_1.isTypeVar)(paramType) && types_1.TypeVarType.isSelf(paramType)) {
|
278
279
|
hasAnnotation = true;
|
279
280
|
}
|
280
281
|
}
|
@@ -287,7 +288,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
287
288
|
// Verify that an unpacked TypedDict doesn't overlap any keyword parameters.
|
288
289
|
if (paramDetails.hasUnpackedTypedDict) {
|
289
290
|
const kwargsIndex = functionTypeResult.functionType.shared.parameters.length - 1;
|
290
|
-
const kwargsType = types_1.FunctionType.
|
291
|
+
const kwargsType = types_1.FunctionType.getParamType(functionTypeResult.functionType, kwargsIndex);
|
291
292
|
if ((0, types_1.isClass)(kwargsType) && kwargsType.shared.typedDictEntries) {
|
292
293
|
const overlappingEntries = new Set();
|
293
294
|
kwargsType.shared.typedDictEntries.knownItems.forEach((_, name) => {
|
@@ -303,9 +304,10 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
303
304
|
}
|
304
305
|
}
|
305
306
|
// Check for invalid use of ParamSpec P.args and P.kwargs.
|
306
|
-
const paramSpecParams = functionTypeResult.functionType.shared.parameters.filter((param) => {
|
307
|
-
|
308
|
-
|
307
|
+
const paramSpecParams = functionTypeResult.functionType.shared.parameters.filter((param, index) => {
|
308
|
+
const paramType = types_1.FunctionType.getParamType(functionTypeResult.functionType, index);
|
309
|
+
if (types_1.FunctionParam.isTypeDeclared(param) && (0, types_1.isTypeVar)(paramType) && (0, types_1.isParamSpec)(paramType)) {
|
310
|
+
if (param.category !== 0 /* ParamCategory.Simple */ && param.name && paramType.priv.paramSpecAccess) {
|
309
311
|
return true;
|
310
312
|
}
|
311
313
|
}
|
@@ -343,10 +345,11 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
343
345
|
if (functionTypeResult) {
|
344
346
|
const annotationNode = param.d.annotation || param.d.annotationComment;
|
345
347
|
if (annotationNode && index < functionTypeResult.functionType.shared.parameters.length) {
|
346
|
-
const paramType = functionTypeResult.functionType
|
348
|
+
const paramType = types_1.FunctionType.getParamType(functionTypeResult.functionType, index);
|
347
349
|
const exemptMethods = ['__init__', '__new__'];
|
348
350
|
if (containingClassNode &&
|
349
351
|
(0, types_1.isTypeVar)(paramType) &&
|
352
|
+
paramType.priv.scopeType === 0 /* TypeVarScopeType.Class */ &&
|
350
353
|
paramType.shared.declaredVariance === 3 /* Variance.Covariant */ &&
|
351
354
|
!paramType.shared.isSynthesized &&
|
352
355
|
!exemptMethods.some((name) => name === functionTypeResult.functionType.shared.name)) {
|
@@ -579,33 +582,31 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
579
582
|
}
|
580
583
|
else {
|
581
584
|
const liveScopes = ParseTreeUtils.getTypeVarScopesForNode(node);
|
582
|
-
declaredReturnType = (0, typeUtils_1.updateTypeWithInternalTypeVars)(declaredReturnType, liveScopes);
|
583
585
|
declaredReturnType = this._evaluator.stripTypeGuard(declaredReturnType);
|
586
|
+
let adjReturnType = (0, typeUtils_1.makeTypeVarsBound)(declaredReturnType, liveScopes);
|
584
587
|
let diagAddendum = new diagnostic_1.DiagnosticAddendum();
|
585
588
|
let returnTypeMatches = false;
|
586
|
-
if (this._evaluator.assignType(
|
587
|
-
/* destTypeVarContext */ new typeVarContext_1.TypeVarContext())) {
|
589
|
+
if (this._evaluator.assignType(adjReturnType, returnType, diagAddendum)) {
|
588
590
|
returnTypeMatches = true;
|
589
591
|
}
|
590
592
|
else {
|
591
593
|
// See if the declared return type includes one or more constrained TypeVars. If so,
|
592
594
|
// try to narrow these TypeVars to a single type.
|
593
595
|
const uniqueTypeVars = (0, typeUtils_1.getTypeVarArgsRecursive)(declaredReturnType);
|
594
|
-
if (uniqueTypeVars && uniqueTypeVars.some((typeVar) =>
|
595
|
-
const
|
596
|
+
if (uniqueTypeVars && uniqueTypeVars.some((typeVar) => types_1.TypeVarType.hasConstraints(typeVar))) {
|
597
|
+
const constraints = new constraintTracker_1.ConstraintTracker();
|
596
598
|
for (const typeVar of uniqueTypeVars) {
|
597
|
-
if (
|
598
|
-
const narrowedType = this._evaluator.narrowConstrainedTypeVar(node, typeVar);
|
599
|
+
if (types_1.TypeVarType.hasConstraints(typeVar)) {
|
600
|
+
const narrowedType = this._evaluator.narrowConstrainedTypeVar(node, types_1.TypeVarType.cloneAsBound(typeVar));
|
599
601
|
if (narrowedType) {
|
600
|
-
|
601
|
-
typeVarContext.addSolveForScope((0, typeUtils_1.getTypeVarScopeId)(typeVar));
|
602
|
+
constraints.setBounds(typeVar, narrowedType);
|
602
603
|
}
|
603
604
|
}
|
604
605
|
}
|
605
|
-
if (!
|
606
|
-
|
607
|
-
|
608
|
-
if (this._evaluator.assignType(
|
606
|
+
if (!constraints.isEmpty()) {
|
607
|
+
adjReturnType = this._evaluator.solveAndApplyConstraints(declaredReturnType, constraints);
|
608
|
+
adjReturnType = (0, typeUtils_1.makeTypeVarsBound)(adjReturnType, liveScopes);
|
609
|
+
if (this._evaluator.assignType(adjReturnType, returnType, diagAddendum)) {
|
609
610
|
returnTypeMatches = true;
|
610
611
|
}
|
611
612
|
}
|
@@ -763,7 +764,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
763
764
|
return true;
|
764
765
|
}
|
765
766
|
visitAugmentedAssignment(node) {
|
766
|
-
this._evaluator.
|
767
|
+
const typeResult = this._evaluator.getTypeResult(node);
|
768
|
+
this._reportDeprecatedUseForOperation(node.d.destExpr, typeResult);
|
767
769
|
return true;
|
768
770
|
}
|
769
771
|
visitIndex(node) {
|
@@ -832,7 +834,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
832
834
|
this._validateContainmentTypes(node);
|
833
835
|
}
|
834
836
|
}
|
835
|
-
this._evaluator.
|
837
|
+
const typeResult = this._evaluator.getTypeResult(node);
|
838
|
+
this._reportDeprecatedUseForOperation(node.d.leftExpr, typeResult);
|
836
839
|
return true;
|
837
840
|
}
|
838
841
|
visitSlice(node) {
|
@@ -851,7 +854,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
851
854
|
if (node.d.operator === 38 /* OperatorType.Not */) {
|
852
855
|
this._validateConditionalIsBool(node.d.expr);
|
853
856
|
}
|
854
|
-
this._evaluator.
|
857
|
+
const typeResult = this._evaluator.getTypeResult(node);
|
858
|
+
this._reportDeprecatedUseForOperation(node.d.expr, typeResult);
|
855
859
|
return true;
|
856
860
|
}
|
857
861
|
visitTernary(node) {
|
@@ -1164,6 +1168,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1164
1168
|
let isTypeBool = true;
|
1165
1169
|
const diag = new diagnostic_1.DiagnosticAddendum();
|
1166
1170
|
this._evaluator.mapSubtypesExpandTypeVars(operandType, /* options */ undefined, (expandedSubtype) => {
|
1171
|
+
var _a;
|
1167
1172
|
if ((0, types_1.isAnyOrUnknown)(expandedSubtype)) {
|
1168
1173
|
return undefined;
|
1169
1174
|
}
|
@@ -1172,8 +1177,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1172
1177
|
return undefined;
|
1173
1178
|
}
|
1174
1179
|
// Invoke the __bool__ method on the type.
|
1175
|
-
const boolReturnType = this._evaluator.getTypeOfMagicMethodCall(expandedSubtype, '__bool__', [], node,
|
1176
|
-
/* inferenceContext */ undefined);
|
1180
|
+
const boolReturnType = (_a = this._evaluator.getTypeOfMagicMethodCall(expandedSubtype, '__bool__', [], node,
|
1181
|
+
/* inferenceContext */ undefined)) === null || _a === void 0 ? void 0 : _a.type;
|
1177
1182
|
if (!boolReturnType || (0, types_1.isAnyOrUnknown)(boolReturnType)) {
|
1178
1183
|
return undefined;
|
1179
1184
|
}
|
@@ -1406,6 +1411,11 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1406
1411
|
isPossiblyTrue = true;
|
1407
1412
|
}
|
1408
1413
|
});
|
1414
|
+
(0, typeUtils_1.doForEachSubtype)(rightType, (rightSubtype) => {
|
1415
|
+
if (this._evaluator.assignType(leftType, rightSubtype)) {
|
1416
|
+
isPossiblyTrue = true;
|
1417
|
+
}
|
1418
|
+
});
|
1409
1419
|
if (!isPossiblyTrue) {
|
1410
1420
|
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnnecessaryComparison, getMessage().format({
|
1411
1421
|
leftType: this._evaluator.printType(leftType, { expandTypeAlias: true }),
|
@@ -1582,13 +1592,13 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1582
1592
|
var _a, _b, _c, _d, _e, _f, _g;
|
1583
1593
|
const nameType = this._evaluator.getType(nameNode);
|
1584
1594
|
``;
|
1585
|
-
if (nameType && (0, types_1.isTypeVar)(nameType) && !
|
1595
|
+
if (nameType && (0, types_1.isTypeVar)(nameType) && !types_1.TypeVarType.isSelf(nameType)) {
|
1586
1596
|
// Does this name refer to a TypeVar that is scoped to this function?
|
1587
1597
|
if (nameType.priv.scopeId === ParseTreeUtils.getScopeIdForNode(node)) {
|
1588
1598
|
// We exempt constrained TypeVars, TypeVars that are type arguments of
|
1589
1599
|
// other types, and ParamSpecs. There are legitimate uses for singleton
|
1590
1600
|
// instances in these particular cases.
|
1591
|
-
let isExempt =
|
1601
|
+
let isExempt = types_1.TypeVarType.hasConstraints(nameType) ||
|
1592
1602
|
nameType.shared.isDefaultExplicit ||
|
1593
1603
|
(exemptBoundTypeVar && subscriptIndex !== undefined) ||
|
1594
1604
|
(0, types_1.isParamSpec)(nameType);
|
@@ -1802,8 +1812,9 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1802
1812
|
if (prevReturnType &&
|
1803
1813
|
returnType &&
|
1804
1814
|
!this._evaluator.assignType(returnType, prevReturnType,
|
1805
|
-
/* diag */ undefined,
|
1806
|
-
/*
|
1815
|
+
/* diag */ undefined,
|
1816
|
+
/* destConstraints */ undefined,
|
1817
|
+
/* srcConstraints */ undefined, 0 /* AssignTypeFlags.Default */)) {
|
1807
1818
|
const altNode = this._findNodeForOverload(node, prevOverload);
|
1808
1819
|
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportOverlappingOverload, localize_1.LocMessage.overloadReturnTypeMismatch().format({
|
1809
1820
|
name: node.d.name.d.value,
|
@@ -1834,6 +1845,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1834
1845
|
return undefined;
|
1835
1846
|
}
|
1836
1847
|
_isOverlappingOverload(functionType, prevOverload, partialOverlap) {
|
1848
|
+
var _a, _b, _c;
|
1837
1849
|
// According to precedent, the __get__ method is special-cased and is
|
1838
1850
|
// exempt from overlapping overload checks. It's not clear why this is
|
1839
1851
|
// the case, but for consistency with other type checkers, we'll honor
|
@@ -1846,24 +1858,49 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1846
1858
|
if (partialOverlap) {
|
1847
1859
|
flags |= 32 /* AssignTypeFlags.PartialOverloadOverlap */;
|
1848
1860
|
}
|
1861
|
+
const functionNode = (_a = functionType.shared.declaration) === null || _a === void 0 ? void 0 : _a.node;
|
1862
|
+
if (functionNode) {
|
1863
|
+
const liveTypeVars = ParseTreeUtils.getTypeVarScopesForNode(functionNode);
|
1864
|
+
functionType = (0, typeUtils_1.makeTypeVarsBound)(functionType, liveTypeVars);
|
1865
|
+
}
|
1866
|
+
// Use the parent node of the declaration in this case so we don't transform
|
1867
|
+
// function-local type variables into bound type variables.
|
1868
|
+
const prevOverloadNode = (_c = (_b = prevOverload.shared.declaration) === null || _b === void 0 ? void 0 : _b.node) === null || _c === void 0 ? void 0 : _c.parent;
|
1869
|
+
if (prevOverloadNode) {
|
1870
|
+
const liveTypeVars = ParseTreeUtils.getTypeVarScopesForNode(prevOverloadNode);
|
1871
|
+
prevOverload = (0, typeUtils_1.makeTypeVarsBound)(prevOverload, liveTypeVars);
|
1872
|
+
}
|
1849
1873
|
return this._evaluator.assignType(functionType, prevOverload,
|
1850
|
-
/* diag */ undefined,
|
1851
|
-
/*
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1855
|
-
|
1856
|
-
|
1874
|
+
/* diag */ undefined,
|
1875
|
+
/* destConstraints */ undefined,
|
1876
|
+
/* srcConstraints */ undefined, flags);
|
1877
|
+
}
|
1878
|
+
// Determines whether the implementation of an overload is compatible with an
|
1879
|
+
// overload signature. To be compatible, the implementation must accept all
|
1880
|
+
// of the same arguments as the overload and return a type that is consistent
|
1881
|
+
// with the overload's return type.
|
1882
|
+
_validateOverloadImplementation(overload, implementation, diag) {
|
1883
|
+
var _a, _b, _c;
|
1884
|
+
const implConstraints = new constraintTracker_1.ConstraintTracker();
|
1885
|
+
const overloadConstraints = new constraintTracker_1.ConstraintTracker();
|
1857
1886
|
// First check the parameters to see if they are assignable.
|
1858
|
-
let isLegal = this._evaluator.assignType(overload, implementation, diag,
|
1887
|
+
let isLegal = this._evaluator.assignType(overload, implementation, diag, overloadConstraints, implConstraints, 64 /* AssignTypeFlags.SkipReturnTypeCheck */ |
|
1859
1888
|
2 /* AssignTypeFlags.ReverseTypeVarMatching */ |
|
1860
1889
|
512 /* AssignTypeFlags.SkipSelfClsTypeCheck */);
|
1861
1890
|
// Now check the return types.
|
1862
|
-
|
1863
|
-
|
1891
|
+
let overloadReturnType = (_a = overload.shared.declaredReturnType) !== null && _a !== void 0 ? _a : this._evaluator.getFunctionInferredReturnType(overload);
|
1892
|
+
let implementationReturnType = this._evaluator.solveAndApplyConstraints(implementation.shared.declaredReturnType || this._evaluator.getFunctionInferredReturnType(implementation), implConstraints);
|
1893
|
+
if ((_c = (_b = implementation.shared.declaration) === null || _b === void 0 ? void 0 : _b.node) === null || _c === void 0 ? void 0 : _c.parent) {
|
1894
|
+
// Use the parent node of the implementation to determine which type variables
|
1895
|
+
// are live. This will include any class-scoped type variables if this is an
|
1896
|
+
// overloaded method.
|
1897
|
+
const liveScopeIds = ParseTreeUtils.getTypeVarScopesForNode(implementation.shared.declaration.node.parent);
|
1898
|
+
implementationReturnType = (0, typeUtils_1.makeTypeVarsBound)(implementationReturnType, liveScopeIds);
|
1899
|
+
overloadReturnType = (0, typeUtils_1.makeTypeVarsBound)(overloadReturnType, liveScopeIds);
|
1900
|
+
}
|
1864
1901
|
const returnDiag = new diagnostic_1.DiagnosticAddendum();
|
1865
1902
|
if (!(0, types_1.isNever)(overloadReturnType) &&
|
1866
|
-
!this._evaluator.assignType(implementationReturnType, overloadReturnType, returnDiag.createAddendum(),
|
1903
|
+
!this._evaluator.assignType(implementationReturnType, overloadReturnType, returnDiag.createAddendum(), implConstraints, overloadConstraints, 0 /* AssignTypeFlags.Default */)) {
|
1867
1904
|
returnDiag.addMessage(localize_1.LocAddendum.functionReturnTypeMismatch().format({
|
1868
1905
|
sourceType: this._evaluator.printType(overloadReturnType),
|
1869
1906
|
destType: this._evaluator.printType(implementationReturnType),
|
@@ -2156,7 +2193,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2156
2193
|
types_1.OverloadedFunctionType.getOverloads(type).forEach((overload, index) => {
|
2157
2194
|
var _a, _b, _c, _d;
|
2158
2195
|
const diag = new diagnostic_1.DiagnosticAddendum();
|
2159
|
-
if (!this.
|
2196
|
+
if (!this._validateOverloadImplementation(overload, implementationFunction, diag)) {
|
2160
2197
|
if (implementationFunction.shared.declaration) {
|
2161
2198
|
const diagnostic = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInconsistentOverload, localize_1.LocMessage.overloadImplementationMismatch().format({
|
2162
2199
|
name,
|
@@ -2994,6 +3031,16 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2994
3031
|
this._reportDeprecatedDiagnostic(node, errorMessage, info.deprecatedMessage);
|
2995
3032
|
}
|
2996
3033
|
}
|
3034
|
+
_reportDeprecatedUseForOperation(node, typeResult) {
|
3035
|
+
const deprecationInfo = typeResult === null || typeResult === void 0 ? void 0 : typeResult.magicMethodDeprecationInfo;
|
3036
|
+
if (!deprecationInfo) {
|
3037
|
+
return;
|
3038
|
+
}
|
3039
|
+
this._reportDeprecatedDiagnostic(node, localize_1.LocMessage.deprecatedMethod().format({
|
3040
|
+
className: deprecationInfo.className,
|
3041
|
+
name: deprecationInfo.methodName,
|
3042
|
+
}), deprecationInfo.deprecatedMessage);
|
3043
|
+
}
|
2997
3044
|
_reportDeprecatedUseForType(node, type, isImportFromTyping = false) {
|
2998
3045
|
var _a, _b, _c;
|
2999
3046
|
if (!type) {
|
@@ -3042,7 +3089,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
3042
3089
|
deprecatedMessage = overload.shared.deprecatedMessage;
|
3043
3090
|
errorMessage = getDeprecatedMessageForFunction(overload);
|
3044
3091
|
}
|
3045
|
-
else if ((0, types_1.isInstantiableClass)(type) &&
|
3092
|
+
else if ((0, types_1.isInstantiableClass)(type) &&
|
3093
|
+
['__init__', '__new__'].includes(overload.shared.name)) {
|
3046
3094
|
deprecatedMessage = overload.shared.deprecatedMessage;
|
3047
3095
|
errorMessage = localize_1.LocMessage.deprecatedConstructor().format({
|
3048
3096
|
name: type.shared.name,
|
@@ -3390,13 +3438,14 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
3390
3438
|
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typeGuardParamCount(), node.d.name);
|
3391
3439
|
}
|
3392
3440
|
if (isTypeIs) {
|
3393
|
-
const
|
3441
|
+
const scopeIds = (0, typeUtils_1.getTypeVarScopeIds)(functionType);
|
3442
|
+
const typeGuardType = (0, typeUtils_1.makeTypeVarsBound)(returnType.priv.typeArgs[0], scopeIds);
|
3394
3443
|
// Determine the type of the first parameter.
|
3395
3444
|
const paramIndex = isMethod && !types_1.FunctionType.isStaticMethod(functionType) ? 1 : 0;
|
3396
3445
|
if (paramIndex >= functionType.shared.parameters.length) {
|
3397
3446
|
return;
|
3398
3447
|
}
|
3399
|
-
const paramType = types_1.FunctionType.
|
3448
|
+
const paramType = (0, typeUtils_1.makeTypeVarsBound)(types_1.FunctionType.getParamType(functionType, paramIndex), scopeIds);
|
3400
3449
|
// Verify that the typeGuardType is a narrower type than the paramType.
|
3401
3450
|
if (!this._evaluator.assignType(paramType, typeGuardType)) {
|
3402
3451
|
const returnAnnotation = node.d.returnAnnotation || ((_a = node.d.funcAnnotationComment) === null || _a === void 0 ? void 0 : _a.d.returnAnnotation);
|
@@ -3446,6 +3495,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
3446
3495
|
if (declaredReturnType) {
|
3447
3496
|
this._reportUnknownReturnResult(node, declaredReturnType);
|
3448
3497
|
this._validateReturnTypeIsNotContravariant(declaredReturnType, returnAnnotation);
|
3498
|
+
const liveScopes = ParseTreeUtils.getTypeVarScopesForNode(node);
|
3499
|
+
declaredReturnType = (0, typeUtils_1.makeTypeVarsBound)(declaredReturnType, liveScopes);
|
3449
3500
|
}
|
3450
3501
|
// Wrap the declared type in a generator type if the function is a generator.
|
3451
3502
|
if (types_1.FunctionType.isGenerator(functionType)) {
|
@@ -3623,13 +3674,13 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
3623
3674
|
];
|
3624
3675
|
if (newMemberTypeResult) {
|
3625
3676
|
this._evaluator.validateCallArgs(errorNode, argList, newMemberTypeResult,
|
3626
|
-
/*
|
3677
|
+
/* constraints */ undefined,
|
3627
3678
|
/* skipUnknownArgCheck */ undefined,
|
3628
3679
|
/* inferenceContext */ undefined);
|
3629
3680
|
}
|
3630
3681
|
if (initMemberTypeResult) {
|
3631
3682
|
this._evaluator.validateCallArgs(errorNode, argList, initMemberTypeResult,
|
3632
|
-
/*
|
3683
|
+
/* constraints */ undefined,
|
3633
3684
|
/* skipUnknownArgCheck */ undefined,
|
3634
3685
|
/* inferenceContext */ undefined);
|
3635
3686
|
}
|
@@ -3688,7 +3739,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
3688
3739
|
return;
|
3689
3740
|
}
|
3690
3741
|
// Verify that the parameter count matches.
|
3691
|
-
const nonDefaultParams = paramListDetails.params.filter((paramInfo) =>
|
3742
|
+
const nonDefaultParams = paramListDetails.params.filter((paramInfo, index) => types_1.FunctionType.getParamDefaultType(postInitType, index) === undefined);
|
3692
3743
|
// We expect to see one param for "self" plus one for each of the InitVars.
|
3693
3744
|
const expectedParamCount = initOnlySymbolMap.size + 1;
|
3694
3745
|
const postInitNode = postInitType.shared.declaration.node;
|
@@ -3707,7 +3758,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
3707
3758
|
const annotationNode = (_a = paramNode === null || paramNode === void 0 ? void 0 : paramNode.d.annotation) !== null && _a !== void 0 ? _a : paramNode === null || paramNode === void 0 ? void 0 : paramNode.d.annotationComment;
|
3708
3759
|
if (types_1.FunctionParam.isTypeDeclared(param) && annotationNode) {
|
3709
3760
|
const fieldType = (_b = this._evaluator.getDeclaredTypeOfSymbol(symbol)) === null || _b === void 0 ? void 0 : _b.type;
|
3710
|
-
const paramType = types_1.FunctionType.
|
3761
|
+
const paramType = types_1.FunctionType.getParamType(postInitType, paramListDetails.params[paramIndex].index);
|
3711
3762
|
const assignTypeDiag = new diagnostic_1.DiagnosticAddendum();
|
3712
3763
|
if (fieldType && !this._evaluator.assignType(paramType, fieldType, assignTypeDiag)) {
|
3713
3764
|
const diagnostic = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.dataClassPostInitType().format({ fieldName }) + assignTypeDiag.getString(), annotationNode);
|
@@ -3890,7 +3941,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
3890
3941
|
const objectObject = types_1.ClassType.cloneAsInstance(objectType);
|
3891
3942
|
const dummyTypeObject = types_1.ClassType.createInstantiable('__varianceDummy', '', '', uri_1.Uri.empty(), 0, 0, undefined, undefined);
|
3892
3943
|
classType.shared.typeParams.forEach((param, paramIndex) => {
|
3893
|
-
// Skip
|
3944
|
+
// Skip TypeVarTuples and ParamSpecs.
|
3894
3945
|
if ((0, types_1.isTypeVarTuple)(param) || (0, types_1.isParamSpec)(param)) {
|
3895
3946
|
return;
|
3896
3947
|
}
|
@@ -4035,12 +4086,12 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4035
4086
|
}
|
4036
4087
|
if (!this._evaluator.assignType(newMemberType, initMemberType,
|
4037
4088
|
/* diag */ undefined,
|
4038
|
-
/*
|
4039
|
-
/*
|
4089
|
+
/* destConstraints */ undefined,
|
4090
|
+
/* srcConstraints */ undefined, 64 /* AssignTypeFlags.SkipReturnTypeCheck */) ||
|
4040
4091
|
!this._evaluator.assignType(initMemberType, newMemberType,
|
4041
4092
|
/* diag */ undefined,
|
4042
|
-
/*
|
4043
|
-
/*
|
4093
|
+
/* destConstraints */ undefined,
|
4094
|
+
/* srcConstraints */ undefined, 64 /* AssignTypeFlags.SkipReturnTypeCheck */)) {
|
4044
4095
|
const displayOnInit = types_1.ClassType.isSameGenericClass(initMethodResult.classType, classType);
|
4045
4096
|
const initDecl = initMemberType.shared.declaration;
|
4046
4097
|
const newDecl = newMemberType.shared.declaration;
|
@@ -4087,16 +4138,17 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4087
4138
|
}
|
4088
4139
|
const diagAddendum = new diagnostic_1.DiagnosticAddendum();
|
4089
4140
|
for (const baseClass of filteredBaseClasses) {
|
4090
|
-
const
|
4141
|
+
const solution = (0, typeUtils_1.buildSolutionFromSpecializedClass)(baseClass);
|
4091
4142
|
for (const baseClassMroClass of baseClass.shared.mro) {
|
4092
4143
|
// There's no need to check for conflicts if this class isn't generic.
|
4093
4144
|
if ((0, types_1.isClass)(baseClassMroClass) && baseClassMroClass.shared.typeParams.length > 0) {
|
4094
|
-
const specializedBaseClassMroClass = (0, typeUtils_1.applySolvedTypeVars)(baseClassMroClass,
|
4145
|
+
const specializedBaseClassMroClass = (0, typeUtils_1.applySolvedTypeVars)(baseClassMroClass, solution);
|
4095
4146
|
// Find the corresponding class in the derived class's MRO list.
|
4096
4147
|
const matchingMroClass = classType.shared.mro.find((mroClass) => (0, types_1.isClass)(mroClass) && types_1.ClassType.isSameGenericClass(mroClass, specializedBaseClassMroClass));
|
4097
4148
|
if (matchingMroClass && (0, types_1.isInstantiableClass)(matchingMroClass)) {
|
4098
|
-
const
|
4099
|
-
const
|
4149
|
+
const scopeIds = (0, typeUtils_1.getTypeVarScopeIds)(classType);
|
4150
|
+
const matchingMroObject = (0, typeUtils_1.makeTypeVarsBound)(types_1.ClassType.cloneAsInstance(matchingMroClass), scopeIds);
|
4151
|
+
const baseClassMroObject = (0, typeUtils_1.makeTypeVarsBound)(types_1.ClassType.cloneAsInstance(specializedBaseClassMroClass), scopeIds);
|
4100
4152
|
if (!this._evaluator.assignType(matchingMroObject, baseClassMroObject)) {
|
4101
4153
|
const diag = new diagnostic_1.DiagnosticAddendum();
|
4102
4154
|
const baseClassObject = (0, typeUtils_1.convertToInstance)(baseClass);
|
@@ -4281,8 +4333,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4281
4333
|
}
|
4282
4334
|
if (!this._evaluator.assignType(overriddenType, childOverrideType !== null && childOverrideType !== void 0 ? childOverrideType : overrideType,
|
4283
4335
|
/* diag */ undefined,
|
4284
|
-
/*
|
4285
|
-
/*
|
4336
|
+
/* destConstraints */ undefined,
|
4337
|
+
/* srcConstraints */ undefined, isInvariant ? 1 /* AssignTypeFlags.EnforceInvariance */ : 0 /* AssignTypeFlags.Default */)) {
|
4286
4338
|
diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportIncompatibleVariableOverride, localize_1.LocMessage.baseClassVariableTypeIncompatible().format({
|
4287
4339
|
classType: childClassType.shared.name,
|
4288
4340
|
name: memberName,
|
@@ -4448,9 +4500,9 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4448
4500
|
}
|
4449
4501
|
const baseTypedDictEntries = (0, typedDicts_1.getTypedDictMembersForClass)(this._evaluator, baseClass,
|
4450
4502
|
/* allowNarrowed */ false);
|
4451
|
-
const
|
4503
|
+
const solution = (0, typeUtils_1.buildSolutionFromSpecializedClass)(baseClass);
|
4452
4504
|
const baseExtraItemsType = baseTypedDictEntries.extraItems
|
4453
|
-
? (0, typeUtils_1.applySolvedTypeVars)(baseTypedDictEntries.extraItems.valueType,
|
4505
|
+
? (0, typeUtils_1.applySolvedTypeVars)(baseTypedDictEntries.extraItems.valueType, solution)
|
4454
4506
|
: types_1.UnknownType.create();
|
4455
4507
|
for (const [name, entry] of typedDictEntries.knownItems) {
|
4456
4508
|
const baseEntry = baseTypedDictEntries.knownItems.get(name);
|
@@ -4462,8 +4514,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4462
4514
|
}
|
4463
4515
|
else if (!this._evaluator.assignType(baseExtraItemsType, entry.valueType,
|
4464
4516
|
/* diag */ undefined,
|
4465
|
-
/*
|
4466
|
-
/*
|
4517
|
+
/* destConstraints */ undefined,
|
4518
|
+
/* srcConstraints */ undefined, !baseTypedDictEntries.extraItems.isReadOnly
|
4467
4519
|
? 1 /* AssignTypeFlags.EnforceInvariance */
|
4468
4520
|
: 0 /* AssignTypeFlags.Default */)) {
|
4469
4521
|
diag.addMessage(localize_1.LocAddendum.typedDictClosedExtraTypeMismatch().format({
|
@@ -4481,8 +4533,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4481
4533
|
if (typedDictEntries.extraItems && baseTypedDictEntries.extraItems) {
|
4482
4534
|
if (!this._evaluator.assignType(baseExtraItemsType, typedDictEntries.extraItems.valueType,
|
4483
4535
|
/* diag */ undefined,
|
4484
|
-
/*
|
4485
|
-
/*
|
4536
|
+
/* destConstraints */ undefined,
|
4537
|
+
/* srcConstraints */ undefined, !baseTypedDictEntries.extraItems.isReadOnly
|
4486
4538
|
? 1 /* AssignTypeFlags.EnforceInvariance */
|
4487
4539
|
: 0 /* AssignTypeFlags.Default */)) {
|
4488
4540
|
diag.addMessage(localize_1.LocAddendum.typedDictClosedExtraTypeMismatch().format({
|
@@ -4794,8 +4846,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4794
4846
|
}
|
4795
4847
|
let diagAddendum = new diagnostic_1.DiagnosticAddendum();
|
4796
4848
|
if (!this._evaluator.assignType(baseType, overrideType, diagAddendum,
|
4797
|
-
/*
|
4798
|
-
/*
|
4849
|
+
/* destConstraints */ undefined,
|
4850
|
+
/* srcConstraints */ undefined, isInvariant ? 1 /* AssignTypeFlags.EnforceInvariance */ : 0 /* AssignTypeFlags.Default */)) {
|
4799
4851
|
if (isInvariant) {
|
4800
4852
|
diagAddendum = new diagnostic_1.DiagnosticAddendum();
|
4801
4853
|
diagAddendum.addMessage(localize_1.LocAddendum.overrideIsInvariant());
|
@@ -5111,6 +5163,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
5111
5163
|
// If there is no type annotation, there's nothing to check because
|
5112
5164
|
// the type will be inferred.d.typeAnnotation
|
5113
5165
|
const paramInfo = functionType.shared.parameters[0];
|
5166
|
+
const paramType = types_1.FunctionType.getParamType(functionType, 0);
|
5114
5167
|
const paramAnnotation = (_a = node.d.params[0].d.annotation) !== null && _a !== void 0 ? _a : node.d.params[0].d.annotationComment;
|
5115
5168
|
if (!paramAnnotation || !paramInfo.name) {
|
5116
5169
|
return;
|
@@ -5119,11 +5172,11 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
5119
5172
|
// use of class-scoped TypeVars, which are not allowed in this context
|
5120
5173
|
// according to the typing spec.
|
5121
5174
|
if (functionType.shared.name === '__init__' && functionType.shared.methodClass) {
|
5122
|
-
const typeVars = (0, typeUtils_1.getTypeVarArgsRecursive)(
|
5175
|
+
const typeVars = (0, typeUtils_1.getTypeVarArgsRecursive)(paramType);
|
5123
5176
|
if (typeVars.some((typeVar) => {
|
5124
5177
|
var _a;
|
5125
5178
|
return typeVar.priv.scopeId === ((_a = functionType.shared.methodClass) === null || _a === void 0 ? void 0 : _a.shared.typeVarScopeId) &&
|
5126
|
-
!
|
5179
|
+
!types_1.TypeVarType.isSelf(typeVar);
|
5127
5180
|
})) {
|
5128
5181
|
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeVarUse, localize_1.LocMessage.initMethodSelfParamTypeVar(), paramAnnotation);
|
5129
5182
|
}
|
@@ -5133,20 +5186,20 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
5133
5186
|
if (types_1.ClassType.isProtocolClass(classType)) {
|
5134
5187
|
return;
|
5135
5188
|
}
|
5136
|
-
const
|
5189
|
+
const concreteParamType = this._evaluator.makeTopLevelTypeVarsConcrete(paramType);
|
5137
5190
|
const expectedType = isCls ? classType : (0, typeUtils_1.convertToInstance)(classType);
|
5138
5191
|
// If the declared type is a protocol class or instance, skip
|
5139
5192
|
// the check. This has legitimate uses for mix-in classes.
|
5140
|
-
if ((0, types_1.isInstantiableClass)(
|
5193
|
+
if ((0, types_1.isInstantiableClass)(concreteParamType) && types_1.ClassType.isProtocolClass(concreteParamType)) {
|
5141
5194
|
return;
|
5142
5195
|
}
|
5143
|
-
if ((0, types_1.isClassInstance)(
|
5196
|
+
if ((0, types_1.isClassInstance)(concreteParamType) && types_1.ClassType.isProtocolClass(concreteParamType)) {
|
5144
5197
|
return;
|
5145
5198
|
}
|
5146
5199
|
// If the method starts with a `*args: P.args`, skip the check.
|
5147
5200
|
if (paramInfo.category === 1 /* ParamCategory.ArgsList */ &&
|
5148
|
-
(0, types_1.isParamSpec)(
|
5149
|
-
|
5201
|
+
(0, types_1.isParamSpec)(paramType) &&
|
5202
|
+
paramType.priv.paramSpecAccess === 'args') {
|
5150
5203
|
return;
|
5151
5204
|
}
|
5152
5205
|
// Don't enforce this for an overloaded method because the "self" param
|
@@ -5163,8 +5216,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
5163
5216
|
types_1.ClassType.isBuiltIn(classType, 'str')) {
|
5164
5217
|
return;
|
5165
5218
|
}
|
5166
|
-
|
5167
|
-
if (!this._evaluator.assignType(paramType, expectedType, /* diag */ undefined, typeVarContext)) {
|
5219
|
+
if (!this._evaluator.assignType(paramType, expectedType)) {
|
5168
5220
|
// We exempt Never from this check because it has a legitimate use in this case.
|
5169
5221
|
if (!(0, types_1.isNever)(paramType)) {
|
5170
5222
|
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.clsSelfParamTypeMismatch().format({
|
@@ -5191,7 +5243,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
5191
5243
|
return;
|
5192
5244
|
}
|
5193
5245
|
const liveScopes = ParseTreeUtils.getTypeVarScopesForNode(node);
|
5194
|
-
declaredReturnType = (0, typeUtils_1.
|
5246
|
+
declaredReturnType = (0, typeUtils_1.makeTypeVarsBound)(declaredReturnType, liveScopes);
|
5195
5247
|
let generatorType;
|
5196
5248
|
if (!enclosingFunctionNode.d.isAsync &&
|
5197
5249
|
(0, types_1.isClassInstance)(declaredReturnType) &&
|