@zzzen/pyright-internal 1.2.0-dev.20260920 → 1.2.0-dev.20260927
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.d.ts +2 -1
- package/dist/analyzer/checker.js +15 -1
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.js +9 -3
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/operations.js +1 -1
- package/dist/analyzer/operations.js.map +1 -1
- package/dist/analyzer/overloadResult.d.ts +15 -0
- package/dist/analyzer/overloadResult.js +233 -0
- package/dist/analyzer/overloadResult.js.map +1 -0
- package/dist/analyzer/overloadResultAdmission.d.ts +20 -0
- package/dist/analyzer/overloadResultAdmission.js +448 -0
- package/dist/analyzer/overloadResultAdmission.js.map +1 -0
- package/dist/analyzer/overloadResultController.d.ts +227 -0
- package/dist/analyzer/overloadResultController.js +904 -0
- package/dist/analyzer/overloadResultController.js.map +1 -0
- package/dist/analyzer/overloadResultSelector.d.ts +24 -0
- package/dist/analyzer/overloadResultSelector.js +131 -0
- package/dist/analyzer/overloadResultSelector.js.map +1 -0
- package/dist/analyzer/parseTreeUtils.d.ts +1 -0
- package/dist/analyzer/parseTreeUtils.js +4 -0
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/program.d.ts +13 -2
- package/dist/analyzer/program.js +98 -46
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/protocols.d.ts +1 -0
- package/dist/analyzer/protocols.js +286 -6
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/sourceFile.d.ts +6 -2
- package/dist/analyzer/sourceFile.js +9 -3
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/tracePrinter.js +4 -0
- package/dist/analyzer/tracePrinter.js.map +1 -1
- package/dist/analyzer/typeCacheUtils.d.ts +4 -0
- package/dist/analyzer/typeCacheUtils.js +36 -0
- package/dist/analyzer/typeCacheUtils.js.map +1 -1
- package/dist/analyzer/typeComplexity.js +2 -0
- package/dist/analyzer/typeComplexity.js.map +1 -1
- package/dist/analyzer/typeEvaluator.d.ts +10 -1
- package/dist/analyzer/typeEvaluator.js +351 -11
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +30 -1
- package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
- package/dist/analyzer/typeGuards.d.ts +1 -1
- package/dist/analyzer/typePrinter.js +8 -0
- package/dist/analyzer/typePrinter.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +1 -1
- package/dist/analyzer/typeUtils.js +29 -26
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typeWalker.d.ts +2 -1
- package/dist/analyzer/typeWalker.js +12 -0
- package/dist/analyzer/typeWalker.js.map +1 -1
- package/dist/analyzer/typedDicts.js +1 -0
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.d.ts +16 -2
- package/dist/analyzer/types.js +94 -2
- package/dist/analyzer/types.js.map +1 -1
- package/dist/common/configOptions.d.ts +1 -0
- package/dist/common/configOptions.js +2 -0
- package/dist/common/configOptions.js.map +1 -1
- package/dist/languageServerBase.js +2 -2
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/callHierarchyProvider.js +3 -2
- package/dist/languageService/callHierarchyProvider.js.map +1 -1
- package/dist/languageService/completionProvider.js +4 -1
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/tests/config.test.js +48 -0
- package/dist/tests/config.test.js.map +1 -1
- package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedFunction.fourslash.js +10 -6
- package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedFunction.fourslash.js.map +1 -1
- package/dist/tests/fourslash/showcallhierarchy.incomingCalls.function.fourslash.js +16 -10
- package/dist/tests/fourslash/showcallhierarchy.incomingCalls.function.fourslash.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.js +10 -9
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/languageServer.test.js +129 -0
- package/dist/tests/languageServer.test.js.map +1 -1
- package/dist/tests/overloadResult.test.d.ts +1 -0
- package/dist/tests/overloadResult.test.js +182 -0
- package/dist/tests/overloadResult.test.js.map +1 -0
- package/dist/tests/overloadResultController.test.d.ts +1 -0
- package/dist/tests/overloadResultController.test.js +2146 -0
- package/dist/tests/overloadResultController.test.js.map +1 -0
- package/dist/tests/protocolRequirement.test.d.ts +1 -0
- package/dist/tests/protocolRequirement.test.js +122 -0
- package/dist/tests/protocolRequirement.test.js.map +1 -0
- package/dist/tests/protocolRequirementAdversarial.test.d.ts +1 -0
- package/dist/tests/protocolRequirementAdversarial.test.js +92 -0
- package/dist/tests/protocolRequirementAdversarial.test.js.map +1 -0
- package/dist/tests/protocolRequirementBoundary.test.d.ts +1 -0
- package/dist/tests/protocolRequirementBoundary.test.js +119 -0
- package/dist/tests/protocolRequirementBoundary.test.js.map +1 -0
- package/dist/tests/protocolRequirementComplexity.test.d.ts +1 -0
- package/dist/tests/protocolRequirementComplexity.test.js +159 -0
- package/dist/tests/protocolRequirementComplexity.test.js.map +1 -0
- package/dist/tests/protocolRequirementCycles.test.d.ts +1 -0
- package/dist/tests/protocolRequirementCycles.test.js +160 -0
- package/dist/tests/protocolRequirementCycles.test.js.map +1 -0
- package/dist/tests/protocolRequirementGeneral.test.d.ts +1 -0
- package/dist/tests/protocolRequirementGeneral.test.js +120 -0
- package/dist/tests/protocolRequirementGeneral.test.js.map +1 -0
- package/dist/tests/protocolRequirementInstances.test.d.ts +1 -0
- package/dist/tests/protocolRequirementInstances.test.js +164 -0
- package/dist/tests/protocolRequirementInstances.test.js.map +1 -0
- package/dist/tests/protocolRequirementListStub.test.d.ts +1 -0
- package/dist/tests/protocolRequirementListStub.test.js +244 -0
- package/dist/tests/protocolRequirementListStub.test.js.map +1 -0
- package/dist/tests/protocolRequirementPopulated.test.d.ts +1 -0
- package/dist/tests/protocolRequirementPopulated.test.js +172 -0
- package/dist/tests/protocolRequirementPopulated.test.js.map +1 -0
- package/dist/tests/protocolRequirementRecursive.test.d.ts +1 -0
- package/dist/tests/protocolRequirementRecursive.test.js +118 -0
- package/dist/tests/protocolRequirementRecursive.test.js.map +1 -0
- package/dist/tests/protocolRequirementSpeculative.test.d.ts +1 -0
- package/dist/tests/protocolRequirementSpeculative.test.js +200 -0
- package/dist/tests/protocolRequirementSpeculative.test.js.map +1 -0
- package/dist/tests/protocolRequirementState.test.d.ts +1 -0
- package/dist/tests/protocolRequirementState.test.js +161 -0
- package/dist/tests/protocolRequirementState.test.js.map +1 -0
- package/dist/tests/testState.test.js +64 -0
- package/dist/tests/testState.test.js.map +1 -1
- package/dist/tests/testUtils.d.ts +6 -1
- package/dist/tests/testUtils.js +11 -6
- package/dist/tests/testUtils.js.map +1 -1
- package/dist/tests/typeCacheIsolation.test.d.ts +1 -0
- package/dist/tests/typeCacheIsolation.test.js +109 -0
- package/dist/tests/typeCacheIsolation.test.js.map +1 -0
- package/dist/tests/typeCacheUtils.test.js +59 -0
- package/dist/tests/typeCacheUtils.test.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +5 -1
- package/dist/tests/typeEvaluator1.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +6 -2
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/dist/tests/typeEvaluator5.test.js +25 -0
- package/dist/tests/typeEvaluator5.test.js.map +1 -1
- package/dist/tests/typeEvaluator6.test.js +7 -23
- package/dist/tests/typeEvaluator6.test.js.map +1 -1
- package/dist/tests/typeEvaluator7.test.js +237 -2
- package/dist/tests/typeEvaluator7.test.js.map +1 -1
- package/dist/tests/typeServer/typeServer.inProc.test.js +86 -0
- package/dist/tests/typeServer/typeServer.inProc.test.js.map +1 -1
- package/dist/tests/typeUtils.test.js +36 -0
- package/dist/tests/typeUtils.test.js.map +1 -1
- package/dist/trace/nativeAdapter.js +1 -5
- package/dist/trace/nativeAdapter.js.map +1 -1
- package/dist/typeServer/protocol/typeServerProtocol.d.ts +8 -2
- package/dist/typeServer/protocol/typeServerProtocol.js +1 -0
- package/dist/typeServer/protocol/typeServerProtocol.js.map +1 -1
- package/dist/typeServer/typeServerConversionUtils.js +9 -0
- package/dist/typeServer/typeServerConversionUtils.js.map +1 -1
- package/package.json +1 -1
|
@@ -97,6 +97,7 @@ const typeGuards_1 = require("./typeGuards");
|
|
|
97
97
|
const TypePrinter = __importStar(require("./typePrinter"));
|
|
98
98
|
const types_1 = require("./types");
|
|
99
99
|
const typeUtils_1 = require("./typeUtils");
|
|
100
|
+
const overloadResultSelector_1 = require("./overloadResultSelector");
|
|
100
101
|
// This table contains the names of several built-in types that
|
|
101
102
|
// are not subscriptable at runtime on older versions of Python.
|
|
102
103
|
// It lists the first version of Python where subscripting is
|
|
@@ -192,6 +193,8 @@ const printExpressionTypes = false;
|
|
|
192
193
|
function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
193
194
|
const nodeInfo = AnalyzerNodeInfo.createAnalyzerNodeInfoAccessor(evaluatorOptions.nodeInfoReader);
|
|
194
195
|
const maxCodeComplexity = evaluatorOptions.maxCodeComplexity;
|
|
196
|
+
const operationController = evaluatorOptions.experimentalOverloadResult ?? evaluatorOptions.testOnlyExpression;
|
|
197
|
+
let operationRouter = evaluatorOptions.experimentalOverloadResult?.isAutomatic ? undefined : operationController;
|
|
195
198
|
const symbolResolutionStack = [];
|
|
196
199
|
const speculativeTypeTracker = new typeCacheUtils_1.SpeculativeTypeTracker();
|
|
197
200
|
const suppressedNodeStack = [];
|
|
@@ -262,6 +265,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
262
265
|
// circular references in complex data structures, so it fails
|
|
263
266
|
// to clean up the objects if we don't help it out.
|
|
264
267
|
function disposeEvaluator() {
|
|
268
|
+
operationController?.dispose?.();
|
|
265
269
|
functionRecursionMap = new Map();
|
|
266
270
|
codeFlowAnalyzerCache = new Map();
|
|
267
271
|
typeCache = new Map();
|
|
@@ -466,10 +470,40 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
466
470
|
}
|
|
467
471
|
return undefined;
|
|
468
472
|
}
|
|
473
|
+
function finishOverloadActivation() {
|
|
474
|
+
if (!returnTypeInferenceTypeCache && !isSpeculativeModeInUse(undefined)) {
|
|
475
|
+
try {
|
|
476
|
+
evaluatorOptions.experimentalOverloadResult.finishActivation();
|
|
477
|
+
}
|
|
478
|
+
finally {
|
|
479
|
+
// Install routing before an activation restart re-enters evaluation.
|
|
480
|
+
if (evaluatorOptions.experimentalOverloadResult.roots.size) {
|
|
481
|
+
operationRouter = operationController;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
function runWithOverloadActivation(callback) {
|
|
487
|
+
return evaluatorOptions.experimentalOverloadResult.runWithActivation(() => {
|
|
488
|
+
const result = callback();
|
|
489
|
+
if (evaluatorOptions.experimentalOverloadResult.hasPendingActivation) {
|
|
490
|
+
finishOverloadActivation();
|
|
491
|
+
}
|
|
492
|
+
return result;
|
|
493
|
+
});
|
|
494
|
+
}
|
|
469
495
|
// Determines the type of the specified node by evaluating it in
|
|
470
496
|
// context, logging any errors in the process. This may require the
|
|
471
497
|
// type of surrounding statements to be evaluated.
|
|
472
498
|
function getType(node) {
|
|
499
|
+
if (evaluatorOptions.experimentalOverloadResult?.needsActivationBoundary()) {
|
|
500
|
+
return runWithOverloadActivation(() => getType(node));
|
|
501
|
+
}
|
|
502
|
+
const canonical = operationRouter?.route?.({ kind: 'query', node })?.result ??
|
|
503
|
+
evaluatorOptions.testOnlyExpression?.query?.(node);
|
|
504
|
+
if (canonical) {
|
|
505
|
+
return canonical.type;
|
|
506
|
+
}
|
|
473
507
|
initializePrefetchedTypes(node);
|
|
474
508
|
let type = evaluateContextualTypeForSubnode(node, () => {
|
|
475
509
|
evaluateTypesForExpressionInContext(node);
|
|
@@ -508,6 +542,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
508
542
|
return type;
|
|
509
543
|
}
|
|
510
544
|
function getTypeResult(node) {
|
|
545
|
+
if (evaluatorOptions.experimentalOverloadResult?.needsActivationBoundary()) {
|
|
546
|
+
return runWithOverloadActivation(() => getTypeResult(node));
|
|
547
|
+
}
|
|
548
|
+
const canonical = operationRouter?.route?.({ kind: 'query', node })?.result ??
|
|
549
|
+
evaluatorOptions.testOnlyExpression?.query?.(node);
|
|
550
|
+
if (canonical) {
|
|
551
|
+
return canonical;
|
|
552
|
+
}
|
|
511
553
|
return evaluateContextualTypeForSubnode(node, () => {
|
|
512
554
|
evaluateTypesForExpressionInContext(node);
|
|
513
555
|
});
|
|
@@ -643,6 +685,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
643
685
|
}
|
|
644
686
|
}
|
|
645
687
|
function getTypeOfExpression(node, flags = 0 /* EvalFlags.None */, inferenceContext) {
|
|
688
|
+
if (evaluatorOptions.experimentalOverloadResult?.needsActivationBoundary()) {
|
|
689
|
+
return runWithOverloadActivation(() => getTypeOfExpression(node, flags, inferenceContext));
|
|
690
|
+
}
|
|
646
691
|
let useTypeFormCache = (flags & 1073741824 /* EvalFlags.TypeFormArg */) !== 0;
|
|
647
692
|
if (inferenceContext) {
|
|
648
693
|
inferenceContext.expectedType = (0, typeUtils_1.transformPossibleRecursiveTypeAlias)(inferenceContext.expectedType);
|
|
@@ -654,6 +699,15 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
654
699
|
if ((flags & 1073741824 /* EvalFlags.TypeFormArg */) !== 0 && (flags & 33554432 /* EvalFlags.NoConvertSpecialForm */) === 0) {
|
|
655
700
|
flags |= 32 /* EvalFlags.NoParamSpec */ | 64 /* EvalFlags.NoTypeVarTuple */;
|
|
656
701
|
}
|
|
702
|
+
const testResult = operationRouter?.route?.({
|
|
703
|
+
kind: 'expression',
|
|
704
|
+
node,
|
|
705
|
+
flags,
|
|
706
|
+
context: inferenceContext,
|
|
707
|
+
})?.result ?? operationRouter?.dispatch(node, flags, inferenceContext);
|
|
708
|
+
if (testResult) {
|
|
709
|
+
return testResult;
|
|
710
|
+
}
|
|
657
711
|
// Is this type already cached?
|
|
658
712
|
const cacheEntry = useTypeFormCache
|
|
659
713
|
? readTypeFormTypeCacheEntry(node, inferenceContext?.expectedType)
|
|
@@ -693,6 +747,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
693
747
|
// at that point.
|
|
694
748
|
initializePrefetchedTypes(node);
|
|
695
749
|
let typeResult = getTypeOfExpressionCore(node, flags, inferenceContext);
|
|
750
|
+
if (evaluatorOptions.experimentalOverloadResult?.hasPendingActivation) {
|
|
751
|
+
finishOverloadActivation();
|
|
752
|
+
}
|
|
753
|
+
if (operationRouter) {
|
|
754
|
+
typeResult = operationRouter.project(node, typeResult);
|
|
755
|
+
}
|
|
696
756
|
// Should we disable type promotions for bytes?
|
|
697
757
|
if ((0, types_1.isInstantiableClass)(typeResult.type) &&
|
|
698
758
|
typeResult.type.priv.includePromotions &&
|
|
@@ -1342,6 +1402,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
1342
1402
|
}
|
|
1343
1403
|
recursionCount++;
|
|
1344
1404
|
switch (type.category) {
|
|
1405
|
+
case 10 /* TypeCategory.OverloadResult */:
|
|
1406
|
+
return true;
|
|
1345
1407
|
case 0 /* TypeCategory.Unbound */:
|
|
1346
1408
|
case 1 /* TypeCategory.Unknown */:
|
|
1347
1409
|
case 2 /* TypeCategory.Any */:
|
|
@@ -1440,6 +1502,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
1440
1502
|
}
|
|
1441
1503
|
recursionCount++;
|
|
1442
1504
|
switch (type.category) {
|
|
1505
|
+
case 10 /* TypeCategory.OverloadResult */:
|
|
1506
|
+
return true;
|
|
1443
1507
|
case 1 /* TypeCategory.Unknown */:
|
|
1444
1508
|
case 4 /* TypeCategory.Function */:
|
|
1445
1509
|
case 5 /* TypeCategory.Overloaded */:
|
|
@@ -2427,6 +2491,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
2427
2491
|
}
|
|
2428
2492
|
return undefined;
|
|
2429
2493
|
}
|
|
2494
|
+
function getFunctionClassType(type) {
|
|
2495
|
+
const classType = (0, types_1.isMethodType)(type) ? prefetched?.methodClass : prefetched?.functionClass;
|
|
2496
|
+
return classType && (0, types_1.isInstantiableClass)(classType) ? classType : undefined;
|
|
2497
|
+
}
|
|
2430
2498
|
function getTypingType(node, symbolName) {
|
|
2431
2499
|
return (getTypeOfModule(node, symbolName, ['typing']) ?? getTypeOfModule(node, symbolName, ['typing_extensions']));
|
|
2432
2500
|
}
|
|
@@ -2571,7 +2639,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
2571
2639
|
}
|
|
2572
2640
|
if (isNodeReachable(node)) {
|
|
2573
2641
|
const fileInfo = nodeInfo.getFileInfo(node);
|
|
2574
|
-
|
|
2642
|
+
const sink = evaluatorOptions.experimentalOverloadResult?.getDiagnosticSink(node) ?? fileInfo.diagnosticSink;
|
|
2643
|
+
return sink.addDiagnosticWithTextRange(diagLevel, message, range ?? node);
|
|
2575
2644
|
}
|
|
2576
2645
|
return undefined;
|
|
2577
2646
|
}
|
|
@@ -3528,7 +3597,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
3528
3597
|
}
|
|
3529
3598
|
else {
|
|
3530
3599
|
// Handle the special case of "reveal_type" and "reveal_locals".
|
|
3531
|
-
if (
|
|
3600
|
+
if (ParseTreeUtils.isImplicitRevealTypeName(node) || name === 'reveal_locals') {
|
|
3532
3601
|
type = types_1.AnyType.create();
|
|
3533
3602
|
}
|
|
3534
3603
|
else {
|
|
@@ -4432,6 +4501,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
4432
4501
|
}
|
|
4433
4502
|
break;
|
|
4434
4503
|
}
|
|
4504
|
+
case 10 /* TypeCategory.OverloadResult */:
|
|
4505
|
+
throw new Error('Overload-result member dispatch is not enabled');
|
|
4435
4506
|
default:
|
|
4436
4507
|
(0, debug_1.assertNever)(baseType);
|
|
4437
4508
|
}
|
|
@@ -6279,6 +6350,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
6279
6350
|
else {
|
|
6280
6351
|
baseTypeResult = getTypeOfExpression(node.d.leftExpr, 2 /* EvalFlags.CallBaseDefaults */ | (flags & 4 /* EvalFlags.ForwardRefs */));
|
|
6281
6352
|
}
|
|
6353
|
+
operationRouter?.beforeCall(node);
|
|
6282
6354
|
const argList = ParseTreeUtils.getArgsByRuntimeOrder(node).map((arg) => {
|
|
6283
6355
|
const functionArg = {
|
|
6284
6356
|
valueExpression: arg.d.valueExpr,
|
|
@@ -6296,8 +6368,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
6296
6368
|
typeResult = getTypeOfSuperCall(node);
|
|
6297
6369
|
}
|
|
6298
6370
|
else if ((0, types_1.isAnyOrUnknown)(baseTypeResult.type) &&
|
|
6299
|
-
node.d.leftExpr
|
|
6300
|
-
node.d.leftExpr.d.value === 'reveal_type') {
|
|
6371
|
+
ParseTreeUtils.isImplicitRevealTypeName(node.d.leftExpr)) {
|
|
6301
6372
|
// Handle the implicit "reveal_type" call.
|
|
6302
6373
|
typeResult = getTypeOfRevealType(node, inferenceContext);
|
|
6303
6374
|
}
|
|
@@ -7058,6 +7129,20 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
7058
7129
|
isTypeIncomplete = true;
|
|
7059
7130
|
}
|
|
7060
7131
|
if (!callResult.argumentErrors && callResult.returnType) {
|
|
7132
|
+
if (evaluatorOptions.experimentalOverloadResult &&
|
|
7133
|
+
!callResult.isTypeIncomplete &&
|
|
7134
|
+
!overload.priv.boundToType &&
|
|
7135
|
+
!overload.shared.methodClass &&
|
|
7136
|
+
!overload.shared.declaration?.isMethod &&
|
|
7137
|
+
errorNode.nodeType === 9 /* ParseNodeType.Call */ &&
|
|
7138
|
+
errorNode.d.leftExpr.nodeType === 38 /* ParseNodeType.Name */ &&
|
|
7139
|
+
errorNode.parent?.nodeType === 3 /* ParseNodeType.Assignment */ &&
|
|
7140
|
+
errorNode.parent.d.rightExpr === errorNode &&
|
|
7141
|
+
expandedArgTypes.length === 1 &&
|
|
7142
|
+
!hasArgTypeOverride &&
|
|
7143
|
+
callResult.argResults) {
|
|
7144
|
+
evaluatorOptions.experimentalOverloadResult.considerActivation(errorNode, callResult.argResults);
|
|
7145
|
+
}
|
|
7061
7146
|
overloadsUsedForCall.push(overload);
|
|
7062
7147
|
matchedOverload = overload;
|
|
7063
7148
|
const matchedOverloadInfo = {
|
|
@@ -7276,6 +7361,115 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
7276
7361
|
});
|
|
7277
7362
|
return winningOverloadIndex === undefined ? undefined : matches[winningOverloadIndex].overload;
|
|
7278
7363
|
}
|
|
7364
|
+
function selectAutomaticOverloadResult(node, limit, proofUnits) {
|
|
7365
|
+
const budget = new overloadResultSelector_1.OverloadSelectionBudget(proofUnits);
|
|
7366
|
+
const coverage = [];
|
|
7367
|
+
const matches = [];
|
|
7368
|
+
const decline = (reason) => ({
|
|
7369
|
+
candidates: [],
|
|
7370
|
+
reason: budget.exceeded ? 'proof-limit' : reason,
|
|
7371
|
+
coverage,
|
|
7372
|
+
matches,
|
|
7373
|
+
units: budget.used,
|
|
7374
|
+
});
|
|
7375
|
+
return useSpeculativeMode(node, () => {
|
|
7376
|
+
const callee = getTypeOfExpression(node.d.leftExpr, 2 /* EvalFlags.NoSpecialize */);
|
|
7377
|
+
if (callee.isIncomplete || callee.typeErrors || !(0, types_1.isOverloaded)(callee.type)) {
|
|
7378
|
+
return decline('not-complete-overloaded-function');
|
|
7379
|
+
}
|
|
7380
|
+
const overloads = types_1.OverloadedType.getOverloads(callee.type);
|
|
7381
|
+
if (overloads.length > limit) {
|
|
7382
|
+
return decline('candidate-limit');
|
|
7383
|
+
}
|
|
7384
|
+
const args = node.d.args.map((arg) => ({
|
|
7385
|
+
argCategory: arg.d.argCategory,
|
|
7386
|
+
valueExpression: arg.d.valueExpr,
|
|
7387
|
+
node: arg,
|
|
7388
|
+
name: arg.d.name,
|
|
7389
|
+
}));
|
|
7390
|
+
const sources = node.d.args.map((arg) => getTypeOfExpression(arg.d.valueExpr));
|
|
7391
|
+
if (sources.some((s) => s.isIncomplete || s.typeErrors || (0, types_1.isAny)(s.type) || !(0, overloadResultSelector_1.isFixedOverloadArgumentShape)(s.type, budget))) {
|
|
7392
|
+
return decline('unsupported-argument-shape');
|
|
7393
|
+
}
|
|
7394
|
+
if (!sources.some((s) => (0, overloadResultSelector_1.hasNestedOverloadAny)(s.type))) {
|
|
7395
|
+
return decline('no-invariant-any');
|
|
7396
|
+
}
|
|
7397
|
+
const returns = [];
|
|
7398
|
+
for (let index = 0; index < overloads.length; index++) {
|
|
7399
|
+
checkForCancellation();
|
|
7400
|
+
const overload = overloads[index];
|
|
7401
|
+
const declaration = overload.shared.declaration;
|
|
7402
|
+
const declaredReturnType = overload.shared.declaredReturnType;
|
|
7403
|
+
const returnType = types_1.FunctionType.getEffectiveReturnType(overload);
|
|
7404
|
+
if (!declaration ||
|
|
7405
|
+
declaration.isMethod ||
|
|
7406
|
+
overload.shared.methodClass ||
|
|
7407
|
+
overload.priv.boundToType ||
|
|
7408
|
+
overload.shared.typeParams.length ||
|
|
7409
|
+
!declaredReturnType ||
|
|
7410
|
+
!returnType ||
|
|
7411
|
+
declaration.node.d.decorators.length !== 1 ||
|
|
7412
|
+
overload.shared.parameters.some((p, i) => p.category !== 0 /* ParamCategory.Simple */ ||
|
|
7413
|
+
!p.name ||
|
|
7414
|
+
p.defaultExpr ||
|
|
7415
|
+
types_1.FunctionType.getParamDefaultType(overload, i))) {
|
|
7416
|
+
return decline('unsupported-signature');
|
|
7417
|
+
}
|
|
7418
|
+
if (!(0, overloadResultSelector_1.isFixedOverloadReturnShape)(declaredReturnType, budget) ||
|
|
7419
|
+
(returnType !== declaredReturnType && !(0, overloadResultSelector_1.isFixedOverloadReturnShape)(returnType, budget))) {
|
|
7420
|
+
return decline('unsupported-return-shape');
|
|
7421
|
+
}
|
|
7422
|
+
const mapping = matchArgsToParams(node, args, { type: overload, isIncomplete: false }, index);
|
|
7423
|
+
if (mapping.isTypeIncomplete) {
|
|
7424
|
+
return decline('incomplete-mapping');
|
|
7425
|
+
}
|
|
7426
|
+
if (mapping.argumentErrors) {
|
|
7427
|
+
continue;
|
|
7428
|
+
}
|
|
7429
|
+
if (mapping.argParams.length !== args.length ||
|
|
7430
|
+
mapping.argParams.some((p, i) => p.argument !== args[i] ||
|
|
7431
|
+
p.isDefaultArg ||
|
|
7432
|
+
p.requiresTypeVarMatching ||
|
|
7433
|
+
!(0, overloadResultSelector_1.isFixedOverloadArgumentShape)(p.paramType, budget))) {
|
|
7434
|
+
return decline('unsupported-mapping');
|
|
7435
|
+
}
|
|
7436
|
+
// This is the ordinary matcher and solver, not a parallel
|
|
7437
|
+
// assignability algorithm. Only complete successful matches count.
|
|
7438
|
+
const matched = useSpeculativeMode(node, () => validateArgTypesWithContext(node, mapping, new constraintTracker_1.ConstraintTracker(), true, undefined));
|
|
7439
|
+
if (matched.isTypeIncomplete || !matched.returnType) {
|
|
7440
|
+
return decline('incomplete-solution');
|
|
7441
|
+
}
|
|
7442
|
+
if (!(0, overloadResultSelector_1.isFixedOverloadReturnShape)(matched.returnType, budget)) {
|
|
7443
|
+
return decline('unsupported-solved-return-shape');
|
|
7444
|
+
}
|
|
7445
|
+
if (matched.argumentErrors) {
|
|
7446
|
+
continue;
|
|
7447
|
+
}
|
|
7448
|
+
const proof = mapping.argParams.map((p, i) => (0, overloadResultSelector_1.getFixedOverloadCoverage)(sources[i].type, p.paramType, budget));
|
|
7449
|
+
const covered = proof.includes('unsupported')
|
|
7450
|
+
? 'unsupported'
|
|
7451
|
+
: proof.includes('not-covered')
|
|
7452
|
+
? 'not-covered'
|
|
7453
|
+
: 'covered';
|
|
7454
|
+
coverage.push(covered);
|
|
7455
|
+
matches.push(index);
|
|
7456
|
+
if (covered === 'unsupported') {
|
|
7457
|
+
return decline('unsupported-coverage');
|
|
7458
|
+
}
|
|
7459
|
+
if (!returns.some((type) => (0, types_1.isTypeSame)(type, matched.returnType))) {
|
|
7460
|
+
returns.push(matched.returnType);
|
|
7461
|
+
}
|
|
7462
|
+
// A covering overload ends the retained prefix; earlier
|
|
7463
|
+
// non-covering matches remain live alternatives.
|
|
7464
|
+
if (covered === 'covered') {
|
|
7465
|
+
break;
|
|
7466
|
+
}
|
|
7467
|
+
}
|
|
7468
|
+
return returns.length > 1
|
|
7469
|
+
? { candidates: returns, reason: 'selected', coverage, matches, units: budget.used }
|
|
7470
|
+
: decline('equivalent-or-single-return');
|
|
7471
|
+
});
|
|
7472
|
+
}
|
|
7279
7473
|
function validateOverloadedArgTypes(errorNode, argList, typeResult, constraints, skipUnknownArgCheck, inferenceContext) {
|
|
7280
7474
|
const filteredMatchResults = [];
|
|
7281
7475
|
let contextFreeArgTypes;
|
|
@@ -12151,8 +12345,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
12151
12345
|
}
|
|
12152
12346
|
// Validate that we received at least two type arguments. One type argument
|
|
12153
12347
|
// is allowed if it's an unpacked TypeVarTuple or tuple. None is also allowed
|
|
12154
|
-
// since it is used to define NoReturn in typeshed stubs).
|
|
12155
|
-
|
|
12348
|
+
// since it is used to define NoReturn in typeshed stubs). No type arguments,
|
|
12349
|
+
// as in "Union[()]", is a runtime error.
|
|
12350
|
+
if (types.length === 0 || (types.length === 1 && !allowSingleTypeArg && !(0, typeUtils_1.isNoneInstance)(types[0]))) {
|
|
12156
12351
|
if ((flags & (256 /* EvalFlags.TypeExpression */ | 1073741824 /* EvalFlags.TypeFormArg */)) !== 0) {
|
|
12157
12352
|
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeArguments, localize_1.LocMessage.unionTypeArgCount(), errorNode);
|
|
12158
12353
|
}
|
|
@@ -12505,6 +12700,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
12505
12700
|
}
|
|
12506
12701
|
}
|
|
12507
12702
|
function evaluateTypesForAssignmentStatement(node) {
|
|
12703
|
+
if (operationRouter?.route?.({
|
|
12704
|
+
kind: 'statement',
|
|
12705
|
+
node,
|
|
12706
|
+
evaluate: () => evaluateTypesForAssignmentStatement(node),
|
|
12707
|
+
})) {
|
|
12708
|
+
return;
|
|
12709
|
+
}
|
|
12508
12710
|
const fileInfo = nodeInfo.getFileInfo(node);
|
|
12509
12711
|
// If the entire statement has already been evaluated, don't
|
|
12510
12712
|
// re-evaluate it.
|
|
@@ -14643,7 +14845,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
14643
14845
|
return exceptionType;
|
|
14644
14846
|
}
|
|
14645
14847
|
if ((0, types_1.isInstantiableClass)(exceptionType)) {
|
|
14646
|
-
if (
|
|
14848
|
+
if ((0, typeUtils_1.derivesFromStdlibClass)(exceptionType, 'BaseException') &&
|
|
14849
|
+
!(0, typeUtils_1.derivesFromStdlibClass)(exceptionType, 'Exception')) {
|
|
14647
14850
|
includesBaseException = true;
|
|
14648
14851
|
}
|
|
14649
14852
|
return types_1.ClassType.cloneAsInstance(exceptionType);
|
|
@@ -15365,6 +15568,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
15365
15568
|
// be evaluated to provide sufficient context for the type. Evaluated types
|
|
15366
15569
|
// are written back to the type cache for later retrieval.
|
|
15367
15570
|
function evaluateTypesForStatement(node) {
|
|
15571
|
+
if (evaluatorOptions.experimentalOverloadResult?.needsActivationBoundary()) {
|
|
15572
|
+
return runWithOverloadActivation(() => evaluateTypesForStatement(node));
|
|
15573
|
+
}
|
|
15368
15574
|
initializePrefetchedTypes(node);
|
|
15369
15575
|
let curNode = node;
|
|
15370
15576
|
while (curNode) {
|
|
@@ -16179,8 +16385,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
16179
16385
|
}
|
|
16180
16386
|
// PEP 563 indicates that if a forward reference can be resolved in the module
|
|
16181
16387
|
// scope (or, by implication, in the builtins scope), it should prefer that
|
|
16182
|
-
// resolution over local resolutions.
|
|
16183
|
-
|
|
16388
|
+
// resolution over local resolutions. This doesn't apply to a PEP 695 "type"
|
|
16389
|
+
// statement's target, which binds synchronously in the scope where it appears
|
|
16390
|
+
// (including a class scope) rather than being deferred like other annotations.
|
|
16391
|
+
const isTypeAliasStatementTarget = symbolWithScope?.symbol
|
|
16392
|
+
.getDeclarations()
|
|
16393
|
+
.some((decl) => decl.type === 4 /* DeclarationType.TypeAlias */);
|
|
16394
|
+
if (symbolWithScope && preferGlobalScope && !isTypeAliasStatementTarget) {
|
|
16184
16395
|
let curSymbolWithScope = symbolWithScope;
|
|
16185
16396
|
while (curSymbolWithScope.scope.type !== 4 /* ScopeType.Module */ &&
|
|
16186
16397
|
curSymbolWithScope.scope.type !== 5 /* ScopeType.Builtin */ &&
|
|
@@ -19317,6 +19528,26 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
19317
19528
|
/* diag */ undefined,
|
|
19318
19529
|
/* constraints */ undefined, 0 /* AssignTypeFlags.Default */, recursionCount));
|
|
19319
19530
|
}
|
|
19531
|
+
// Types like "bytes", "bytearray" and "memoryview" support cross-type
|
|
19532
|
+
// content comparisons via "==" and "!=", even though they're otherwise
|
|
19533
|
+
// unrelated (non-overlapping) types. Use derivesFromStdlibClass to check
|
|
19534
|
+
// membership in this group across the MRO.
|
|
19535
|
+
function isBytesLikeType(type) {
|
|
19536
|
+
return ((0, typeUtils_1.derivesFromStdlibClass)(type, 'bytes') ||
|
|
19537
|
+
(0, typeUtils_1.derivesFromStdlibClass)(type, 'bytearray') ||
|
|
19538
|
+
(0, typeUtils_1.derivesFromStdlibClass)(type, 'memoryview'));
|
|
19539
|
+
}
|
|
19540
|
+
// Determines whether the two types are both members of the "bytes-like"
|
|
19541
|
+
// group of types ("bytes", "bytearray" and "memoryview"). Pyright models
|
|
19542
|
+
// this relationship as a "type promotion" (used elsewhere for
|
|
19543
|
+
// assignability), but that grouping is also useful for determining
|
|
19544
|
+
// whether two otherwise-disjoint built-in types can be compared with
|
|
19545
|
+
// "==" or "!=", since these types share compatible "__eq__" semantics
|
|
19546
|
+
// regardless of whether the "disableBytesTypePromotions" setting allows
|
|
19547
|
+
// the assignment.
|
|
19548
|
+
function isTypePromotionRelated(leftType, rightType) {
|
|
19549
|
+
return isBytesLikeType(leftType) && isBytesLikeType(rightType);
|
|
19550
|
+
}
|
|
19320
19551
|
// Determines whether the two types are potentially comparable -- i.e.
|
|
19321
19552
|
// their types overlap in such a way that it makes sense for them to
|
|
19322
19553
|
// be compared with an == or != operator. The functional also supports
|
|
@@ -19407,6 +19638,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
19407
19638
|
}
|
|
19408
19639
|
return boolVal === (intVal === 1);
|
|
19409
19640
|
}
|
|
19641
|
+
// Distinct bytes-like classes support cross-type equality regardless
|
|
19642
|
+
// of disableBytesTypePromotions. Don't apply this to the same class:
|
|
19643
|
+
// different bytes literals must remain disjoint.
|
|
19644
|
+
if (!assumeIsOperator &&
|
|
19645
|
+
!types_1.ClassType.isSameGenericClass(leftType, rightType) &&
|
|
19646
|
+
isTypePromotionRelated(leftType, rightType)) {
|
|
19647
|
+
return true;
|
|
19648
|
+
}
|
|
19410
19649
|
return false;
|
|
19411
19650
|
}
|
|
19412
19651
|
}
|
|
@@ -19897,8 +20136,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
19897
20136
|
destParamDetails.firstPositionOrKeywordIndex < srcParamDetails.positionOnlyParamCount &&
|
|
19898
20137
|
!targetIncludesParamSpec) {
|
|
19899
20138
|
diag?.createAddendum().addMessage(localize_1.LocAddendum.argsPositionOnly().format({
|
|
19900
|
-
expected:
|
|
19901
|
-
received:
|
|
20139
|
+
expected: destParamDetails.firstPositionOrKeywordIndex,
|
|
20140
|
+
received: srcParamDetails.positionOnlyParamCount,
|
|
19902
20141
|
}));
|
|
19903
20142
|
canAssign = false;
|
|
19904
20143
|
}
|
|
@@ -21396,6 +21635,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
21396
21635
|
getNoneType,
|
|
21397
21636
|
getUnionClassType,
|
|
21398
21637
|
getTypeClassType,
|
|
21638
|
+
getFunctionClassType,
|
|
21399
21639
|
getBuiltInObject,
|
|
21400
21640
|
getTypingType,
|
|
21401
21641
|
getTypeCheckerInternalsType,
|
|
@@ -21424,6 +21664,106 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
|
21424
21664
|
printControlFlowGraph,
|
|
21425
21665
|
};
|
|
21426
21666
|
const codeFlowEngine = (0, codeFlowEngine_1.getCodeFlowEngine)(evaluatorInterface, speculativeTypeTracker, nodeInfo);
|
|
21667
|
+
if (evaluatorOptions.testOnlyMemberAccess) {
|
|
21668
|
+
const { nodes, install } = evaluatorOptions.testOnlyMemberAccess;
|
|
21669
|
+
install((node, baseTypeResult) => {
|
|
21670
|
+
(0, debug_1.assert)(nodes.has(node));
|
|
21671
|
+
return getTypeOfMemberAccessWithBaseType(node, baseTypeResult, { method: 'get' }, 2 /* EvalFlags.NoSpecialize */);
|
|
21672
|
+
});
|
|
21673
|
+
}
|
|
21674
|
+
evaluatorOptions.experimentalOverloadResult?.installSelector(selectAutomaticOverloadResult);
|
|
21675
|
+
evaluatorOptions.experimentalOverloadResult?.installActivationBoundary(() => !returnTypeInferenceTypeCache && !isSpeculativeModeInUse(undefined), finishOverloadActivation);
|
|
21676
|
+
evaluatorOptions.experimentalOverloadResult?.installCheckerHandoff((root, expression, result, callback) => {
|
|
21677
|
+
const ids = evaluatorOptions.experimentalOverloadResult.roots.get(root);
|
|
21678
|
+
const isComplete = (value) => !value.isIncomplete &&
|
|
21679
|
+
!value.typeErrors &&
|
|
21680
|
+
!((0, types_1.isFunction)(value.type) && types_1.FunctionType.isPartiallyEvaluated(value.type)) &&
|
|
21681
|
+
!((0, types_1.isClass)(value.type) && types_1.ClassType.isPartiallyEvaluated(value.type));
|
|
21682
|
+
if (!ids ||
|
|
21683
|
+
returnTypeInferenceTypeCache ||
|
|
21684
|
+
isSpeculativeModeInUse(undefined) ||
|
|
21685
|
+
typeCache.get(expression.id)?.typeResult !== result ||
|
|
21686
|
+
typeCache.get(expression.id)?.flags !== 0 /* EvalFlags.None */ ||
|
|
21687
|
+
!isComplete(result)) {
|
|
21688
|
+
return false;
|
|
21689
|
+
}
|
|
21690
|
+
for (const id of ids) {
|
|
21691
|
+
const entry = typeCache.get(id);
|
|
21692
|
+
if ((entry && !isComplete(entry.typeResult)) || typeFormTypeCache.has(id)) {
|
|
21693
|
+
return false;
|
|
21694
|
+
}
|
|
21695
|
+
}
|
|
21696
|
+
// Continue synchronously before this candidate's isolation unwinds. No
|
|
21697
|
+
// saved cache set or result is restored, and the checker reads live entries.
|
|
21698
|
+
checkForCancellation();
|
|
21699
|
+
callback();
|
|
21700
|
+
return true;
|
|
21701
|
+
});
|
|
21702
|
+
evaluatorOptions.experimentalOverloadResult?.installQueryCache((root, node) => {
|
|
21703
|
+
const roots = evaluatorOptions.experimentalOverloadResult.roots;
|
|
21704
|
+
const ids = roots.get(root);
|
|
21705
|
+
const isOrdinaryContext = () => !returnTypeInferenceTypeCache && !isSpeculativeModeInUse(undefined);
|
|
21706
|
+
if (!ids || !isOrdinaryContext()) {
|
|
21707
|
+
return undefined;
|
|
21708
|
+
}
|
|
21709
|
+
const isComplete = (result) => !result.isIncomplete &&
|
|
21710
|
+
!((0, types_1.isFunction)(result.type) && types_1.FunctionType.isPartiallyEvaluated(result.type)) &&
|
|
21711
|
+
!((0, types_1.isClass)(result.type) && types_1.ClassType.isPartiallyEvaluated(result.type));
|
|
21712
|
+
const queryEntry = readContextualTypeCacheEntryForNode(node);
|
|
21713
|
+
if (!queryEntry || !isComplete(queryEntry.typeResult)) {
|
|
21714
|
+
return undefined;
|
|
21715
|
+
}
|
|
21716
|
+
const entries = [...ids].map((id) => ({
|
|
21717
|
+
id,
|
|
21718
|
+
runtime: typeCache.get(id),
|
|
21719
|
+
expected: expectedTypeCache.get(id),
|
|
21720
|
+
typeForm: typeFormTypeCache.get(id),
|
|
21721
|
+
}));
|
|
21722
|
+
const areComplete = () => entries.every((entry) => (!entry.runtime || isComplete(entry.runtime.typeResult)) &&
|
|
21723
|
+
(!entry.typeForm || entry.typeForm.every((e) => isComplete(e.typeResult))));
|
|
21724
|
+
if (!areComplete()) {
|
|
21725
|
+
return undefined;
|
|
21726
|
+
}
|
|
21727
|
+
// This is a validity guard, not a saved public answer. Reuse only while
|
|
21728
|
+
// the complete, privately restored cache set is still installed.
|
|
21729
|
+
return () => {
|
|
21730
|
+
const valid = isOrdinaryContext() &&
|
|
21731
|
+
roots.get(root) === ids &&
|
|
21732
|
+
readContextualTypeCacheEntryForNode(node) === queryEntry &&
|
|
21733
|
+
areComplete() &&
|
|
21734
|
+
entries.every((entry) => typeCache.get(entry.id) === entry.runtime &&
|
|
21735
|
+
expectedTypeCache.get(entry.id) === entry.expected &&
|
|
21736
|
+
typeFormTypeCache.get(entry.id) === entry.typeForm);
|
|
21737
|
+
if (valid) {
|
|
21738
|
+
checkForCancellation();
|
|
21739
|
+
}
|
|
21740
|
+
return valid;
|
|
21741
|
+
};
|
|
21742
|
+
});
|
|
21743
|
+
if (operationController) {
|
|
21744
|
+
const { roots } = operationController;
|
|
21745
|
+
operationController.installCacheIsolation({
|
|
21746
|
+
evict(root) {
|
|
21747
|
+
const ids = roots.get(root);
|
|
21748
|
+
(0, debug_1.assert)(ids && ids.size <= 256);
|
|
21749
|
+
(0, debug_1.assert)(!returnTypeInferenceTypeCache && !isSpeculativeModeInUse(undefined));
|
|
21750
|
+
ids.forEach((id) => {
|
|
21751
|
+
typeCache.delete(id);
|
|
21752
|
+
expectedTypeCache.delete(id);
|
|
21753
|
+
typeFormTypeCache.delete(id);
|
|
21754
|
+
});
|
|
21755
|
+
speculativeTypeTracker.evictCacheEntries(ids);
|
|
21756
|
+
},
|
|
21757
|
+
isolate(root, callback, retain = false) {
|
|
21758
|
+
const ids = roots.get(root);
|
|
21759
|
+
(0, debug_1.assert)(ids && ids.size <= 256);
|
|
21760
|
+
// Native argument speculation can query earlier, disjoint operations
|
|
21761
|
+
// through code flow. Never isolate a root that overlaps that context.
|
|
21762
|
+
(0, debug_1.assert)(!returnTypeInferenceTypeCache && speculativeTypeTracker.canUseNodeCacheIsolation(root));
|
|
21763
|
+
return (0, typeCacheUtils_1.useNodeCacheIsolation)(typeCache, ids, () => (0, typeCacheUtils_1.useNodeCacheIsolation)(expectedTypeCache, ids, () => (0, typeCacheUtils_1.useNodeCacheIsolation)(typeFormTypeCache, ids, () => speculativeTypeTracker.useNodeCacheIsolation(ids, callback, root), retain), retain), retain);
|
|
21764
|
+
},
|
|
21765
|
+
});
|
|
21766
|
+
}
|
|
21427
21767
|
return evaluatorInterface;
|
|
21428
21768
|
}
|
|
21429
21769
|
//# sourceMappingURL=typeEvaluator.js.map
|