@zzzen/pyright-internal 1.2.0-dev.20220710 → 1.2.0-dev.20220717
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 +14 -0
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.js +47 -42
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.d.ts +0 -1
- package/dist/analyzer/codeFlowEngine.js +190 -196
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/codeFlowTypes.d.ts +1 -1
- package/dist/analyzer/codeFlowTypes.js.map +1 -1
- package/dist/analyzer/constraintSolver.js +1 -1
- package/dist/analyzer/constraintSolver.js.map +1 -1
- package/dist/analyzer/importResolver.js +3 -2
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.d.ts +3 -0
- package/dist/analyzer/parseTreeUtils.js +37 -3
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/service.js +1 -0
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/sourceFile.js +40 -9
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/typeEvaluator.d.ts +1 -1
- package/dist/analyzer/typeEvaluator.js +147 -82
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +4 -4
- package/dist/analyzer/typeEvaluatorWithTracker.js +8 -7
- package/dist/analyzer/typeEvaluatorWithTracker.js.map +1 -1
- package/dist/analyzer/typeGuards.js +1 -1
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +2 -1
- package/dist/analyzer/typeUtils.js +80 -4
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typedDicts.d.ts +1 -0
- package/dist/analyzer/typedDicts.js +22 -1
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.d.ts +8 -0
- package/dist/analyzer/types.js +53 -0
- package/dist/analyzer/types.js.map +1 -1
- package/dist/common/diagnostic.d.ts +2 -1
- package/dist/common/diagnostic.js +2 -1
- package/dist/common/diagnostic.js.map +1 -1
- package/dist/common/diagnosticSink.d.ts +3 -0
- package/dist/common/diagnosticSink.js +15 -2
- package/dist/common/diagnosticSink.js.map +1 -1
- package/dist/languageServerBase.d.ts +2 -6
- package/dist/languageServerBase.js +27 -16
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/completionProvider.d.ts +15 -11
- package/dist/languageService/completionProvider.js +76 -5
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/tooltipUtils.js +1 -3
- package/dist/languageService/tooltipUtils.js.map +1 -1
- package/dist/localization/localize.d.ts +5 -0
- package/dist/localization/localize.js +2 -0
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.en-us.json +2 -0
- package/dist/parser/parser.js +9 -1
- package/dist/parser/parser.js.map +1 -1
- package/dist/pyright.js +3 -1
- package/dist/pyright.js.map +1 -1
- package/dist/pyrightFileSystem.d.ts +1 -1
- package/dist/pyrightFileSystem.js +11 -1
- package/dist/pyrightFileSystem.js.map +1 -1
- package/dist/tests/chainedSourceFiles.test.js +2 -0
- package/dist/tests/chainedSourceFiles.test.js.map +1 -1
- package/dist/tests/fourslash/completions.commitChars.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.commitChars.fourslash.js +47 -0
- package/dist/tests/fourslash/completions.commitChars.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.triggers.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.triggers.fourslash.js +29 -0
- package/dist/tests/fourslash/completions.triggers.fourslash.js.map +1 -0
- package/dist/tests/fourslash/fourslash.d.ts +1 -0
- package/dist/tests/harness/fourslash/testState.js +11 -2
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/pyrightFileSystem.test.js +28 -0
- package/dist/tests/pyrightFileSystem.test.js.map +1 -1
- package/dist/tests/testUtils.d.ts +2 -1
- package/dist/tests/testUtils.js +8 -5
- package/dist/tests/testUtils.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +2 -2
- package/dist/tests/typeEvaluator1.test.js.map +1 -1
- package/dist/tests/typeEvaluator2.test.js +12 -4
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +1 -1
- package/dist/tests/typeEvaluator4.test.js +8 -0
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/package.json +1 -1
@@ -182,6 +182,9 @@ const maxReturnTypeInferenceArgumentCount = 6;
|
|
182
182
|
// when its parameters are unannotated? We want to keep this
|
183
183
|
// pretty low because this can be very costly.
|
184
184
|
const maxReturnTypeInferenceCodeFlowComplexity = 8;
|
185
|
+
// What is the max number of return types cached per function
|
186
|
+
// when using call-site inference?
|
187
|
+
const maxCallSiteReturnTypeCacheSize = 8;
|
185
188
|
// How many entries in a list, set, or dict should we examine
|
186
189
|
// when inferring the type? We need to cut it off at some point
|
187
190
|
// to avoid excessive computation.
|
@@ -209,7 +212,7 @@ const maxLiteralMathSubtypeCount = 64;
|
|
209
212
|
// off code flow analysis at some point for code flow graphs that are too
|
210
213
|
// complex. Otherwise we risk overflowing the stack or incurring extremely
|
211
214
|
// long analysis times. This number has been tuned empirically.
|
212
|
-
exports.maxCodeComplexity =
|
215
|
+
exports.maxCodeComplexity = 768;
|
213
216
|
function createTypeEvaluator(importLookup, evaluatorOptions) {
|
214
217
|
const symbolResolutionStack = [];
|
215
218
|
const typeCacheFlags = new Map();
|
@@ -231,6 +234,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
231
234
|
let functionObj;
|
232
235
|
let tupleClassType;
|
233
236
|
let boolClassType;
|
237
|
+
let intClassType;
|
234
238
|
let strClassType;
|
235
239
|
let dictClassType;
|
236
240
|
let typedDictClassType;
|
@@ -452,6 +456,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
452
456
|
noneType = getTypeshedType(node, 'NoneType') || types_1.AnyType.create();
|
453
457
|
tupleClassType = getBuiltInType(node, 'tuple');
|
454
458
|
boolClassType = getBuiltInType(node, 'bool');
|
459
|
+
intClassType = getBuiltInType(node, 'int');
|
455
460
|
strClassType = getBuiltInType(node, 'str');
|
456
461
|
dictClassType = getBuiltInType(node, 'dict');
|
457
462
|
typedDictClassType = getTypingType(node, '_TypedDict');
|
@@ -1272,10 +1277,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
1272
1277
|
addOneFunctionToSignature(type);
|
1273
1278
|
}
|
1274
1279
|
else {
|
1275
|
-
type.
|
1276
|
-
|
1277
|
-
addOneFunctionToSignature(func);
|
1278
|
-
}
|
1280
|
+
types_1.OverloadedFunctionType.getOverloads(type).forEach((func) => {
|
1281
|
+
addOneFunctionToSignature(func);
|
1279
1282
|
});
|
1280
1283
|
}
|
1281
1284
|
}
|
@@ -1477,13 +1480,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
1477
1480
|
return subtype;
|
1478
1481
|
}
|
1479
1482
|
if ((0, types_1.isClassInstance)(subtype)) {
|
1480
|
-
const awaitReturnType = getSpecializedReturnType(subtype, '__await__', errorNode);
|
1483
|
+
const awaitReturnType = getSpecializedReturnType(subtype, '__await__', [], errorNode);
|
1481
1484
|
if (awaitReturnType) {
|
1482
1485
|
if ((0, types_1.isAnyOrUnknown)(awaitReturnType)) {
|
1483
1486
|
return awaitReturnType;
|
1484
1487
|
}
|
1485
1488
|
if ((0, types_1.isClassInstance)(awaitReturnType)) {
|
1486
|
-
const iterReturnType = getSpecializedReturnType(awaitReturnType, '__iter__', errorNode);
|
1489
|
+
const iterReturnType = getSpecializedReturnType(awaitReturnType, '__iter__', [], errorNode);
|
1487
1490
|
if (iterReturnType) {
|
1488
1491
|
const generatorReturnType = getReturnTypeFromGenerator(awaitReturnType);
|
1489
1492
|
if (generatorReturnType) {
|
@@ -1528,18 +1531,27 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
1528
1531
|
subtype.tupleTypeArguments.length === 0) {
|
1529
1532
|
return types_1.NeverType.createNever();
|
1530
1533
|
}
|
1531
|
-
iterReturnType = getSpecializedReturnType(subtype, iterMethodName, errorNode);
|
1534
|
+
iterReturnType = getSpecializedReturnType(subtype, iterMethodName, [], errorNode);
|
1532
1535
|
}
|
1533
1536
|
else if (types_1.TypeBase.isInstantiable(subtype) &&
|
1534
1537
|
subtype.details.effectiveMetaclass &&
|
1535
1538
|
(0, types_1.isInstantiableClass)(subtype.details.effectiveMetaclass)) {
|
1536
|
-
iterReturnType = getSpecializedReturnType(types_1.ClassType.cloneAsInstance(subtype.details.effectiveMetaclass), iterMethodName, errorNode, subtype);
|
1539
|
+
iterReturnType = getSpecializedReturnType(types_1.ClassType.cloneAsInstance(subtype.details.effectiveMetaclass), iterMethodName, [], errorNode, subtype);
|
1537
1540
|
}
|
1538
1541
|
if (!iterReturnType) {
|
1539
1542
|
// There was no __iter__. See if we can fall back to
|
1540
1543
|
// the __getitem__ method instead.
|
1541
|
-
if ((0, types_1.isClassInstance)(subtype)) {
|
1542
|
-
const getItemReturnType = getSpecializedReturnType(subtype, '__getitem__',
|
1544
|
+
if (!isAsync && (0, types_1.isClassInstance)(subtype)) {
|
1545
|
+
const getItemReturnType = getSpecializedReturnType(subtype, '__getitem__', [
|
1546
|
+
{
|
1547
|
+
argumentCategory: 0 /* Simple */,
|
1548
|
+
typeResult: {
|
1549
|
+
type: intClassType && (0, types_1.isInstantiableClass)(intClassType)
|
1550
|
+
? types_1.ClassType.cloneAsInstance(intClassType)
|
1551
|
+
: types_1.UnknownType.create(),
|
1552
|
+
},
|
1553
|
+
},
|
1554
|
+
], errorNode);
|
1543
1555
|
if (getItemReturnType) {
|
1544
1556
|
return getItemReturnType;
|
1545
1557
|
}
|
@@ -1554,7 +1566,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
1554
1566
|
return subtype;
|
1555
1567
|
}
|
1556
1568
|
if ((0, types_1.isClassInstance)(subtype)) {
|
1557
|
-
const nextReturnType = getSpecializedReturnType(subtype, nextMethodName, errorNode);
|
1569
|
+
const nextReturnType = getSpecializedReturnType(subtype, nextMethodName, [], errorNode);
|
1558
1570
|
if (!nextReturnType) {
|
1559
1571
|
iterReturnTypeDiag.addMessage(localize_1.Localizer.Diagnostic.methodNotDefinedOnType().format({
|
1560
1572
|
name: nextMethodName,
|
@@ -1607,12 +1619,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
1607
1619
|
if ((0, types_1.isClass)(subtype)) {
|
1608
1620
|
let iterReturnType;
|
1609
1621
|
if (types_1.TypeBase.isInstance(subtype)) {
|
1610
|
-
iterReturnType = getSpecializedReturnType(subtype, iterMethodName, errorNode);
|
1622
|
+
iterReturnType = getSpecializedReturnType(subtype, iterMethodName, [], errorNode);
|
1611
1623
|
}
|
1612
1624
|
else if (types_1.TypeBase.isInstantiable(subtype) &&
|
1613
1625
|
subtype.details.effectiveMetaclass &&
|
1614
1626
|
(0, types_1.isInstantiableClass)(subtype.details.effectiveMetaclass)) {
|
1615
|
-
iterReturnType = getSpecializedReturnType(types_1.ClassType.cloneAsInstance(subtype.details.effectiveMetaclass), iterMethodName, errorNode, subtype);
|
1627
|
+
iterReturnType = getSpecializedReturnType(types_1.ClassType.cloneAsInstance(subtype.details.effectiveMetaclass), iterMethodName, [], errorNode, subtype);
|
1616
1628
|
}
|
1617
1629
|
if (iterReturnType) {
|
1618
1630
|
return makeTopLevelTypeVarsConcrete(iterReturnType);
|
@@ -1760,6 +1772,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
1760
1772
|
fileInfo.diagnosticSink.addUnusedCodeWithTextRange(localize_1.Localizer.Diagnostic.unreachableCode(), textRange);
|
1761
1773
|
}
|
1762
1774
|
}
|
1775
|
+
function addUnreachableCode(node, textRange) {
|
1776
|
+
if (!isDiagnosticSuppressedForNode(node)) {
|
1777
|
+
const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
|
1778
|
+
fileInfo.diagnosticSink.addUnreachableCodeWithTextRange(localize_1.Localizer.Diagnostic.unreachableCode(), textRange);
|
1779
|
+
}
|
1780
|
+
}
|
1763
1781
|
function addDeprecated(message, node) {
|
1764
1782
|
if (!isDiagnosticSuppressedForNode(node)) {
|
1765
1783
|
const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
|
@@ -2514,7 +2532,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
2514
2532
|
}
|
2515
2533
|
return undefined;
|
2516
2534
|
}
|
2517
|
-
function getSpecializedReturnType(objType, memberName, errorNode, bindToClass) {
|
2535
|
+
function getSpecializedReturnType(objType, memberName, argList, errorNode, bindToClass) {
|
2518
2536
|
const classMember = (0, typeUtils_1.lookUpObjectMember)(objType, memberName, 8 /* SkipInstanceVariables */);
|
2519
2537
|
if (!classMember) {
|
2520
2538
|
return undefined;
|
@@ -2523,13 +2541,23 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
2523
2541
|
if ((0, types_1.isAnyOrUnknown)(memberType)) {
|
2524
2542
|
return memberType;
|
2525
2543
|
}
|
2526
|
-
if ((0, types_1.isFunction)(memberType)) {
|
2544
|
+
if ((0, types_1.isFunction)(memberType) || (0, types_1.isOverloadedFunction)(memberType)) {
|
2527
2545
|
const methodType = bindFunctionToClassOrObject(bindToClass || objType, memberType, classMember && (0, types_1.isInstantiableClass)(classMember.classType) ? classMember.classType : undefined, errorNode,
|
2528
2546
|
/* recursionCount */ undefined,
|
2529
2547
|
/* treatConstructorAsClassMember */ false,
|
2530
2548
|
/* firstParamType */ bindToClass);
|
2531
2549
|
if (methodType) {
|
2532
|
-
|
2550
|
+
if ((0, types_1.isOverloadedFunction)(methodType)) {
|
2551
|
+
if (errorNode) {
|
2552
|
+
const bestOverload = getBestOverloadForArguments(errorNode, methodType, argList);
|
2553
|
+
if (bestOverload) {
|
2554
|
+
return getFunctionEffectiveReturnType(bestOverload);
|
2555
|
+
}
|
2556
|
+
}
|
2557
|
+
}
|
2558
|
+
else {
|
2559
|
+
return getFunctionEffectiveReturnType(methodType);
|
2560
|
+
}
|
2533
2561
|
}
|
2534
2562
|
}
|
2535
2563
|
return undefined;
|
@@ -3701,7 +3729,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
3701
3729
|
isFinal = types_1.FunctionType.isFinal(concreteSubtype);
|
3702
3730
|
}
|
3703
3731
|
else {
|
3704
|
-
const impl =
|
3732
|
+
const impl = types_1.OverloadedFunctionType.getImplementation(concreteSubtype);
|
3705
3733
|
if (impl) {
|
3706
3734
|
isFinal = types_1.FunctionType.isFinal(impl);
|
3707
3735
|
}
|
@@ -4444,7 +4472,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
4444
4472
|
if (typeResult.isIncomplete) {
|
4445
4473
|
isPositionalIndexTypeIncomplete = true;
|
4446
4474
|
}
|
4447
|
-
const iterableType = getTypeOfIterator(exprType, /* isAsync */ false, arg) || types_1.UnknownType.create();
|
4475
|
+
const iterableType = getTypeOfIterator(exprType, /* isAsync */ false, arg.valueExpression) || types_1.UnknownType.create();
|
4448
4476
|
tupleEntries.push(iterableType);
|
4449
4477
|
});
|
4450
4478
|
positionalIndexType = makeTupleObject(tupleEntries, unpackedListArgs.length > 0);
|
@@ -5086,7 +5114,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
5086
5114
|
bindToType: resultIsInstance && bindToType && (0, types_1.isInstantiableClass)(bindToType)
|
5087
5115
|
? types_1.ClassType.cloneAsInstance(bindToType)
|
5088
5116
|
: bindToType,
|
5089
|
-
isSuperCall: true,
|
5090
5117
|
};
|
5091
5118
|
}
|
5092
5119
|
}
|
@@ -5098,7 +5125,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
5098
5125
|
if (targetClassType.details.mro.some((mroBase) => (0, types_1.isAnyOrUnknown)(mroBase))) {
|
5099
5126
|
return {
|
5100
5127
|
type: types_1.UnknownType.create(),
|
5101
|
-
isSuperCall: true,
|
5102
5128
|
node,
|
5103
5129
|
};
|
5104
5130
|
}
|
@@ -5108,7 +5134,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
5108
5134
|
if ((0, types_1.isInstantiableClass)(baseClassType)) {
|
5109
5135
|
return {
|
5110
5136
|
type: resultIsInstance ? types_1.ClassType.cloneAsInstance(baseClassType) : baseClassType,
|
5111
|
-
isSuperCall: true,
|
5112
5137
|
node,
|
5113
5138
|
};
|
5114
5139
|
}
|
@@ -5116,7 +5141,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
5116
5141
|
}
|
5117
5142
|
return {
|
5118
5143
|
type: types_1.UnknownType.create(),
|
5119
|
-
isSuperCall: true,
|
5120
5144
|
node,
|
5121
5145
|
};
|
5122
5146
|
}
|
@@ -5210,15 +5234,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
5210
5234
|
let overloadIndex = 0;
|
5211
5235
|
let matches = [];
|
5212
5236
|
// Create a list of potential overload matches based on arguments.
|
5213
|
-
type.
|
5237
|
+
types_1.OverloadedFunctionType.getOverloads(type).forEach((overload) => {
|
5214
5238
|
useSpeculativeMode(errorNode, () => {
|
5215
|
-
|
5216
|
-
|
5217
|
-
|
5218
|
-
matches.push(matchResults);
|
5219
|
-
}
|
5220
|
-
overloadIndex++;
|
5239
|
+
const matchResults = matchFunctionArgumentsToParameters(errorNode, argList, overload, overloadIndex);
|
5240
|
+
if (!matchResults.argumentErrors) {
|
5241
|
+
matches.push(matchResults);
|
5221
5242
|
}
|
5243
|
+
overloadIndex++;
|
5222
5244
|
});
|
5223
5245
|
});
|
5224
5246
|
matches = sortOverloadsByBestMatch(matches);
|
@@ -5255,17 +5277,15 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
5255
5277
|
// cache or record any diagnostics at this stage.
|
5256
5278
|
useSpeculativeMode(errorNode, () => {
|
5257
5279
|
let overloadIndex = 0;
|
5258
|
-
type.
|
5280
|
+
types_1.OverloadedFunctionType.getOverloads(type).forEach((overload) => {
|
5259
5281
|
// Consider only the functions that have the @overload decorator,
|
5260
5282
|
// not the final function that omits the overload. This is the
|
5261
5283
|
// intended behavior according to PEP 484.
|
5262
|
-
|
5263
|
-
|
5264
|
-
|
5265
|
-
filteredMatchResults.push(matchResults);
|
5266
|
-
}
|
5267
|
-
overloadIndex++;
|
5284
|
+
const matchResults = matchFunctionArgumentsToParameters(errorNode, argList, overload, overloadIndex);
|
5285
|
+
if (!matchResults.argumentErrors) {
|
5286
|
+
filteredMatchResults.push(matchResults);
|
5268
5287
|
}
|
5288
|
+
overloadIndex++;
|
5269
5289
|
});
|
5270
5290
|
});
|
5271
5291
|
filteredMatchResults = sortOverloadsByBestMatch(filteredMatchResults);
|
@@ -12110,7 +12130,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
12110
12130
|
}
|
12111
12131
|
// For "async while", an implicit "await" is performed.
|
12112
12132
|
if (isAsync) {
|
12113
|
-
memberReturnType = getTypeOfAwaitable(memberReturnType, node);
|
12133
|
+
memberReturnType = getTypeOfAwaitable(memberReturnType, node.expression);
|
12114
12134
|
}
|
12115
12135
|
return memberReturnType;
|
12116
12136
|
}
|
@@ -13376,7 +13396,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
13376
13396
|
else if (node.parent &&
|
13377
13397
|
node.parent.nodeType === 35 /* MemberAccess */ &&
|
13378
13398
|
node === node.parent.memberName) {
|
13379
|
-
let baseType =
|
13399
|
+
let baseType = getType(node.parent.leftExpression);
|
13380
13400
|
if (baseType) {
|
13381
13401
|
baseType = makeTopLevelTypeVarsConcrete(baseType);
|
13382
13402
|
const memberName = node.parent.memberName.value;
|
@@ -13451,7 +13471,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
13451
13471
|
const argNode = node.parent;
|
13452
13472
|
const paramName = node.value;
|
13453
13473
|
if (argNode.parent && argNode.parent.nodeType === 9 /* Call */) {
|
13454
|
-
const baseType =
|
13474
|
+
const baseType = getType(argNode.parent.leftExpression);
|
13455
13475
|
if (baseType) {
|
13456
13476
|
if ((0, types_1.isFunction)(baseType) && baseType.details.declaration) {
|
13457
13477
|
const paramDecl = getDeclarationFromFunctionNamedParameter(baseType, paramName);
|
@@ -14292,9 +14312,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
14292
14312
|
if (returnTypeInferenceContextStack.length >= maxReturnTypeInferenceStackSize) {
|
14293
14313
|
return undefined;
|
14294
14314
|
}
|
14315
|
+
const paramTypes = [];
|
14316
|
+
let isResultFromCache = false;
|
14295
14317
|
// Suppress diagnostics because we don't want to generate errors.
|
14296
14318
|
suppressDiagnostics(functionNode, () => {
|
14297
|
-
var _a;
|
14319
|
+
var _a, _b;
|
14298
14320
|
// Allocate a new temporary type cache for the context of just
|
14299
14321
|
// this function so we can analyze it separately without polluting
|
14300
14322
|
// the main type cache.
|
@@ -14337,13 +14359,26 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
14337
14359
|
if (!paramType) {
|
14338
14360
|
paramType = types_1.UnknownType.create();
|
14339
14361
|
}
|
14362
|
+
paramTypes.push(paramType);
|
14340
14363
|
writeTypeCache(param.name, paramType, 0 /* None */, /* isIncomplete */ false);
|
14341
14364
|
}
|
14342
14365
|
});
|
14343
14366
|
// Don't bother trying to determine the contextual return
|
14344
14367
|
// type if none of the argument types are known.
|
14345
14368
|
if (!allArgTypesAreUnknown) {
|
14346
|
-
|
14369
|
+
// See if the return type is already cached. If so, skip the
|
14370
|
+
// inference step, which is potentially very expensive.
|
14371
|
+
const cacheEntry = (_a = functionType.functionType.callSiteReturnTypeCache) === null || _a === void 0 ? void 0 : _a.find((entry) => {
|
14372
|
+
return (entry.paramTypes.length === paramTypes.length &&
|
14373
|
+
entry.paramTypes.every((t, i) => (0, types_1.isTypeSame)(t, paramTypes[i])));
|
14374
|
+
});
|
14375
|
+
if (cacheEntry) {
|
14376
|
+
contextualReturnType = cacheEntry.returnType;
|
14377
|
+
isResultFromCache = true;
|
14378
|
+
}
|
14379
|
+
else {
|
14380
|
+
contextualReturnType = (_b = inferFunctionReturnType(functionNode, types_1.FunctionType.isAbstractMethod(type))) === null || _b === void 0 ? void 0 : _b.type;
|
14381
|
+
}
|
14347
14382
|
}
|
14348
14383
|
}
|
14349
14384
|
finally {
|
@@ -14357,6 +14392,20 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
14357
14392
|
if (types_1.FunctionType.isWrapReturnTypeInAwait(type) && !(0, types_1.isNever)(contextualReturnType)) {
|
14358
14393
|
contextualReturnType = createAwaitableReturnType(functionNode, contextualReturnType, !!((_a = type.details.declaration) === null || _a === void 0 ? void 0 : _a.isGenerator));
|
14359
14394
|
}
|
14395
|
+
if (!isResultFromCache) {
|
14396
|
+
// Cache the resulting type.
|
14397
|
+
if (!functionType.functionType.callSiteReturnTypeCache) {
|
14398
|
+
functionType.functionType.callSiteReturnTypeCache = [];
|
14399
|
+
}
|
14400
|
+
if (functionType.functionType.callSiteReturnTypeCache.length >= maxCallSiteReturnTypeCacheSize) {
|
14401
|
+
functionType.functionType.callSiteReturnTypeCache =
|
14402
|
+
functionType.functionType.callSiteReturnTypeCache.slice(1);
|
14403
|
+
}
|
14404
|
+
functionType.functionType.callSiteReturnTypeCache.push({
|
14405
|
+
paramTypes,
|
14406
|
+
returnType: contextualReturnType,
|
14407
|
+
});
|
14408
|
+
}
|
14360
14409
|
return contextualReturnType;
|
14361
14410
|
}
|
14362
14411
|
return undefined;
|
@@ -15240,11 +15289,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
15240
15289
|
// Find first overloaded function that matches the parameters.
|
15241
15290
|
// We don't want to pollute the current typeVarContext, so we'll
|
15242
15291
|
// make a copy of the existing one if it's specified.
|
15243
|
-
const overloads = concreteSrcType
|
15292
|
+
const overloads = types_1.OverloadedFunctionType.getOverloads(concreteSrcType);
|
15244
15293
|
const overloadIndex = overloads.findIndex((overload) => {
|
15245
|
-
if (!types_1.FunctionType.isOverloaded(overload)) {
|
15246
|
-
return false;
|
15247
|
-
}
|
15248
15294
|
return assignType(destType, overload, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), destTypeVarContext === null || destTypeVarContext === void 0 ? void 0 : destTypeVarContext.clone(), srcTypeVarContext === null || srcTypeVarContext === void 0 ? void 0 : srcTypeVarContext.clone(), flags, recursionCount);
|
15249
15295
|
});
|
15250
15296
|
if (overloadIndex < 0) {
|
@@ -15268,10 +15314,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
15268
15314
|
if ((0, types_1.isOverloadedFunction)(destType)) {
|
15269
15315
|
const overloadDiag = diag === null || diag === void 0 ? void 0 : diag.createAddendum();
|
15270
15316
|
// All overloads in the dest must be assignable.
|
15271
|
-
const isAssignable = destType.
|
15272
|
-
if (!types_1.FunctionType.isOverloaded(destOverload)) {
|
15273
|
-
return true;
|
15274
|
-
}
|
15317
|
+
const isAssignable = types_1.OverloadedFunctionType.getOverloads(destType).every((destOverload) => {
|
15275
15318
|
if (destTypeVarContext) {
|
15276
15319
|
destTypeVarContext.addSolveForScope((0, typeUtils_1.getTypeVarScopeId)(destOverload));
|
15277
15320
|
}
|
@@ -15403,6 +15446,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
15403
15446
|
}
|
15404
15447
|
// For union sources, all of the types need to be assignable to the dest.
|
15405
15448
|
let isIncompatible = false;
|
15449
|
+
// Sort the subtypes so we have a deterministic order for unions.
|
15406
15450
|
(0, typeUtils_1.doForEachSubtype)(srcType, (subtype, subtypeIndex) => {
|
15407
15451
|
if (isIncompatible) {
|
15408
15452
|
return;
|
@@ -15427,7 +15471,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
15427
15471
|
isIncompatible = true;
|
15428
15472
|
}
|
15429
15473
|
}
|
15430
|
-
}
|
15474
|
+
},
|
15475
|
+
/* sortSubtypes */ true);
|
15431
15476
|
if (isIncompatible) {
|
15432
15477
|
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.typeAssignmentMismatch().format({
|
15433
15478
|
sourceType: printType(srcType),
|
@@ -16402,22 +16447,41 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
16402
16447
|
return narrowedType;
|
16403
16448
|
}
|
16404
16449
|
function validateOverrideMethod(baseMethod, overrideMethod, diag, enforceParamNames = true) {
|
16405
|
-
var _a, _b;
|
16406
|
-
// If we're overriding an overloaded method, uses the implementation.
|
16407
|
-
if ((0, types_1.isOverloadedFunction)(baseMethod)) {
|
16408
|
-
const implementation = baseMethod.overloads.find((overload) => !types_1.FunctionType.isOverloaded(overload));
|
16409
|
-
// If the overloaded method doesn't have an implementation, skip the check.
|
16410
|
-
if (!implementation) {
|
16411
|
-
return true;
|
16412
|
-
}
|
16413
|
-
baseMethod = implementation;
|
16414
|
-
}
|
16415
16450
|
// If we're overriding a non-method with a method, report it as an error.
|
16416
16451
|
// This occurs when a non-property overrides a property.
|
16417
|
-
if (!(0, types_1.isFunction)(baseMethod)) {
|
16452
|
+
if (!(0, types_1.isFunction)(baseMethod) && !(0, types_1.isOverloadedFunction)(baseMethod)) {
|
16418
16453
|
diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideType().format({ type: printType(baseMethod) }));
|
16419
16454
|
return false;
|
16420
16455
|
}
|
16456
|
+
if ((0, types_1.isFunction)(baseMethod)) {
|
16457
|
+
// Handle the easy case - a simple function overriding another simple function.
|
16458
|
+
if ((0, types_1.isFunction)(overrideMethod)) {
|
16459
|
+
return validateOverrideMethodInternal(baseMethod, overrideMethod, diag, enforceParamNames);
|
16460
|
+
}
|
16461
|
+
// For an overload overriding a base method, at least one overload
|
16462
|
+
// must be compatible with the base method.
|
16463
|
+
if (types_1.OverloadedFunctionType.getOverloads(overrideMethod).some((overrideOverload) => {
|
16464
|
+
return validateOverrideMethodInternal(baseMethod, overrideOverload,
|
16465
|
+
/* diag */ undefined, enforceParamNames);
|
16466
|
+
})) {
|
16467
|
+
return true;
|
16468
|
+
}
|
16469
|
+
// Or the implementation must be compatible.
|
16470
|
+
const overrideImplementation = types_1.OverloadedFunctionType.getImplementation(overrideMethod);
|
16471
|
+
if (overrideImplementation) {
|
16472
|
+
if (validateOverrideMethodInternal(baseMethod, overrideImplementation,
|
16473
|
+
/* diag */ undefined, enforceParamNames)) {
|
16474
|
+
return true;
|
16475
|
+
}
|
16476
|
+
}
|
16477
|
+
diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideNoOverloadMatches());
|
16478
|
+
return false;
|
16479
|
+
}
|
16480
|
+
// TODO - need to implement the case where the base method is overloaded
|
16481
|
+
return true;
|
16482
|
+
}
|
16483
|
+
function validateOverrideMethodInternal(baseMethod, overrideMethod, diag, enforceParamNames) {
|
16484
|
+
var _a, _b;
|
16421
16485
|
const baseParamDetails = (0, typeUtils_1.getParameterListDetails)(baseMethod);
|
16422
16486
|
const overrideParamDetails = (0, typeUtils_1.getParameterListDetails)(overrideMethod);
|
16423
16487
|
let canOverride = true;
|
@@ -16425,19 +16489,19 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
16425
16489
|
// an incompatible type.
|
16426
16490
|
if (types_1.FunctionType.isStaticMethod(baseMethod)) {
|
16427
16491
|
if (!types_1.FunctionType.isStaticMethod(overrideMethod)) {
|
16428
|
-
diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideNotStaticMethod());
|
16492
|
+
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideNotStaticMethod());
|
16429
16493
|
canOverride = false;
|
16430
16494
|
}
|
16431
16495
|
}
|
16432
16496
|
else if (types_1.FunctionType.isClassMethod(baseMethod)) {
|
16433
16497
|
if (!types_1.FunctionType.isClassMethod(overrideMethod)) {
|
16434
|
-
diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideNotClassMethod());
|
16498
|
+
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideNotClassMethod());
|
16435
16499
|
canOverride = false;
|
16436
16500
|
}
|
16437
16501
|
}
|
16438
16502
|
if (types_1.FunctionType.isInstanceMethod(baseMethod)) {
|
16439
16503
|
if (!types_1.FunctionType.isInstanceMethod(overrideMethod)) {
|
16440
|
-
diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideNotInstanceMethod());
|
16504
|
+
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideNotInstanceMethod());
|
16441
16505
|
canOverride = false;
|
16442
16506
|
}
|
16443
16507
|
}
|
@@ -16462,7 +16526,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
16462
16526
|
}
|
16463
16527
|
}
|
16464
16528
|
if (foundParamCountMismatch) {
|
16465
|
-
diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overridePositionalParamCount().format({
|
16529
|
+
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overridePositionalParamCount().format({
|
16466
16530
|
baseCount: baseParamDetails.params.length,
|
16467
16531
|
overrideCount: overrideParamDetails.params.length,
|
16468
16532
|
}));
|
@@ -16489,13 +16553,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
16489
16553
|
if (overrideParam.category === 0 /* Simple */) {
|
16490
16554
|
if (enforceParamNames) {
|
16491
16555
|
if (overrideParamDetails.params[i].source === typeUtils_1.ParameterSource.PositionOnly) {
|
16492
|
-
diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideParamNamePositionOnly().format({
|
16556
|
+
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideParamNamePositionOnly().format({
|
16493
16557
|
index: i + 1,
|
16494
16558
|
baseName: baseParam.name || '*',
|
16495
16559
|
}));
|
16496
16560
|
}
|
16497
16561
|
else {
|
16498
|
-
diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideParamName().format({
|
16562
|
+
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideParamName().format({
|
16499
16563
|
index: i + 1,
|
16500
16564
|
baseName: baseParam.name || '*',
|
16501
16565
|
overrideName: overrideParam.name || '*',
|
@@ -16507,7 +16571,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
16507
16571
|
}
|
16508
16572
|
else if (i < overrideParamDetails.positionOnlyParamCount &&
|
16509
16573
|
i >= baseParamDetails.positionOnlyParamCount) {
|
16510
|
-
diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideParamNamePositionOnly().format({
|
16574
|
+
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideParamNamePositionOnly().format({
|
16511
16575
|
index: i + 1,
|
16512
16576
|
baseName: baseParam.name || '*',
|
16513
16577
|
}));
|
@@ -16520,8 +16584,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
16520
16584
|
const overrideIsSynthesizedTypeVar = (0, types_1.isTypeVar)(overrideParamType) && overrideParamType.details.isSynthesized;
|
16521
16585
|
if (!baseIsSynthesizedTypeVar && !overrideIsSynthesizedTypeVar) {
|
16522
16586
|
if (baseParam.category !== overrideParam.category ||
|
16523
|
-
!assignType(overrideParamType, baseParamType, diag.createAddendum(), new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(overrideMethod)), new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(baseMethod)), 8 /* SkipSolveTypeVars */)) {
|
16524
|
-
diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideParamType().format({
|
16587
|
+
!assignType(overrideParamType, baseParamType, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(overrideMethod)), new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(baseMethod)), 8 /* SkipSolveTypeVars */)) {
|
16588
|
+
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideParamType().format({
|
16525
16589
|
index: i + 1,
|
16526
16590
|
baseType: printType(baseParamType),
|
16527
16591
|
overrideType: printType(overrideParamType),
|
@@ -16530,7 +16594,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
16530
16594
|
}
|
16531
16595
|
}
|
16532
16596
|
if (baseParamDetails.params[i].param.hasDefault && !overrideParamDetails.params[i].param.hasDefault) {
|
16533
|
-
diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideParamNoDefault().format({
|
16597
|
+
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideParamNoDefault().format({
|
16534
16598
|
index: i + 1,
|
16535
16599
|
}));
|
16536
16600
|
canOverride = false;
|
@@ -16540,7 +16604,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
16540
16604
|
// Check for a *args match.
|
16541
16605
|
if (baseParamDetails.argsIndex !== undefined) {
|
16542
16606
|
if (overrideParamDetails.argsIndex === undefined) {
|
16543
|
-
diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideParamNameMissing().format({
|
16607
|
+
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideParamNameMissing().format({
|
16544
16608
|
name: (_a = baseParamDetails.params[baseParamDetails.argsIndex].param.name) !== null && _a !== void 0 ? _a : '?',
|
16545
16609
|
}));
|
16546
16610
|
canOverride = false;
|
@@ -16548,9 +16612,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
16548
16612
|
else {
|
16549
16613
|
const overrideParamType = overrideParamDetails.params[overrideParamDetails.argsIndex].type;
|
16550
16614
|
const baseParamType = baseParamDetails.params[baseParamDetails.argsIndex].type;
|
16551
|
-
if (!assignType(overrideParamType, baseParamType, diag.createAddendum(), new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(overrideMethod)),
|
16615
|
+
if (!assignType(overrideParamType, baseParamType, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(overrideMethod)),
|
16552
16616
|
/* srcTypeVarContext */ undefined, 8 /* SkipSolveTypeVars */)) {
|
16553
|
-
diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideParamKeywordType().format({
|
16617
|
+
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideParamKeywordType().format({
|
16554
16618
|
name: (_b = overrideParamDetails.params[overrideParamDetails.argsIndex].param.name) !== null && _b !== void 0 ? _b : '?',
|
16555
16619
|
baseType: printType(baseParamType),
|
16556
16620
|
overrideType: printType(overrideParamType),
|
@@ -16568,7 +16632,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
16568
16632
|
var _a, _b, _c;
|
16569
16633
|
const overrideParamInfo = overrideWkOnlyParams.find((pi) => paramInfo.param.name === pi.param.name);
|
16570
16634
|
if (!overrideParamInfo && overrideParamDetails.kwargsIndex === undefined) {
|
16571
|
-
diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideParamNameMissing().format({
|
16635
|
+
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideParamNameMissing().format({
|
16572
16636
|
name: (_a = paramInfo.param.name) !== null && _a !== void 0 ? _a : '?',
|
16573
16637
|
}));
|
16574
16638
|
canOverride = false;
|
@@ -16578,9 +16642,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
16578
16642
|
if (!targetParamType) {
|
16579
16643
|
targetParamType = overrideParamDetails.params[overrideParamDetails.kwargsIndex].type;
|
16580
16644
|
}
|
16581
|
-
if (!assignType(targetParamType, paramInfo.type, diag.createAddendum(), new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(overrideMethod)),
|
16645
|
+
if (!assignType(targetParamType, paramInfo.type, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(overrideMethod)),
|
16582
16646
|
/* srcTypeVarContext */ undefined, 8 /* SkipSolveTypeVars */)) {
|
16583
|
-
diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideParamKeywordType().format({
|
16647
|
+
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideParamKeywordType().format({
|
16584
16648
|
name: (_b = paramInfo.param.name) !== null && _b !== void 0 ? _b : '?',
|
16585
16649
|
baseType: printType(paramInfo.type),
|
16586
16650
|
overrideType: printType(targetParamType),
|
@@ -16589,7 +16653,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
16589
16653
|
}
|
16590
16654
|
if (overrideParamInfo) {
|
16591
16655
|
if (paramInfo.param.hasDefault && !overrideParamInfo.param.hasDefault) {
|
16592
|
-
diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideParamKeywordNoDefault().format({
|
16656
|
+
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideParamKeywordNoDefault().format({
|
16593
16657
|
name: (_c = overrideParamInfo.param.name) !== null && _c !== void 0 ? _c : '?',
|
16594
16658
|
}));
|
16595
16659
|
canOverride = false;
|
@@ -16605,7 +16669,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
16605
16669
|
if (!baseParamInfo) {
|
16606
16670
|
if (baseParamDetails.kwargsIndex === undefined) {
|
16607
16671
|
if (!paramInfo.param.hasDefault) {
|
16608
|
-
diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideParamNameExtra().format({
|
16672
|
+
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideParamNameExtra().format({
|
16609
16673
|
name: (_a = paramInfo.param.name) !== null && _a !== void 0 ? _a : '?',
|
16610
16674
|
}));
|
16611
16675
|
canOverride = false;
|
@@ -16616,9 +16680,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
16616
16680
|
// Now check the return type.
|
16617
16681
|
const baseReturnType = getFunctionEffectiveReturnType(baseMethod);
|
16618
16682
|
const overrideReturnType = getFunctionEffectiveReturnType(overrideMethod);
|
16619
|
-
if (!assignType(baseReturnType, overrideReturnType, diag.createAddendum(), new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(baseMethod)),
|
16683
|
+
if (!assignType(baseReturnType, overrideReturnType, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(baseMethod)),
|
16620
16684
|
/* srcTypeVarContext */ undefined, 8 /* SkipSolveTypeVars */)) {
|
16621
|
-
diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideReturnType().format({
|
16685
|
+
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideReturnType().format({
|
16622
16686
|
baseType: printType(baseReturnType),
|
16623
16687
|
overrideType: printType(overrideReturnType),
|
16624
16688
|
}));
|
@@ -17033,6 +17097,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
17033
17097
|
addWarning,
|
17034
17098
|
addInformation,
|
17035
17099
|
addUnusedCode,
|
17100
|
+
addUnreachableCode,
|
17036
17101
|
addDeprecated,
|
17037
17102
|
addDiagnostic,
|
17038
17103
|
addDiagnosticForTextRange,
|