8000 Fixed an issue that resulted in an unnecessary use of memory when tra… · codemuse-app/scip-python@523762d · GitHub
[go: up one dir, main page]

Skip to content

Commit 523762d

Browse files
committed
Fixed an issue that resulted in an unnecessary use of memory when transforming certain types that include TypeVars.
1 parent d8f878c commit 523762d

File tree

2 files changed

+29
-27
lines changed

2 files changed

+29
-27
lines changed

packages/pyright-internal/src/analyzer/typeEvaluator.ts

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10879,34 +10879,36 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
1087910879
for (let i = 0; i < passCount; i++) {
1088010880
useSpeculativeMode(errorNode, () => {
1088110881
matchResults.argParams.forEach((argParam) => {
10882-
if (argParam.requiresTypeVarMatching) {
10883-
// Populate the typeVarContext for the argument. If the argument
10884-
// is an overload function, skip it during the first pass
10885-
// because the selection of the proper overload may depend
10886-
// on type arguments supplied by other function arguments.
10887-
// Set useNarrowBoundOnly to true the first time through
10888-
// the loop if we're going to go through the loop multiple
10889-
// times.
10890-
const argResult = validateArgType(
10891-
argParam,
10892-
typeVarContext,
10893-
{ type, isIncomplete: matchResults.isTypeIncomplete },
10894-
skipUnknownAr 8000 gCheck,
10895-
/* skipOverloadArg */ i === 0,
10896-
/* useNarrowBoundOnly */ passCount > 1 && i === 0,
10897-
typeCondition
10898-
);
10882+
if (!argParam.requiresTypeVarMatching) {
10883+
return;
10884+
}
1089910885

10900-
if (argResult.isTypeIncomplete) {
10901-
isTypeIncomplete = true;
10902-
}
10886+
// Populate the typeVarContext for the argument. If the argument
10887+
// is an overload function, skip it during the first pass
10888+
// because the selection of the proper overload may depend
10889+
// on type arguments supplied by other function arguments.
10890+
// Set useNarrowBoundOnly to true the first time through
10891+
// the loop if we're going to go through the loop multiple
10892+
// times.
10893+
const argResult = validateArgType(
10894+
argParam,
10895+
typeVarContext,
10896+
{ type, isIncomplete: matchResults.isTypeIncomplete },
10897+
skipUnknownArgCheck,
10898+
/* skipOverloadArg */ i === 0,
10899+
/* useNarrowBoundOnly */ passCount > 1 && i === 0,
10900+
typeCondition
10901+
);
1090310902

10904-
// If we skipped a overload arg during the first pass,
10905-
// add another pass to ensure that we handle all of the
10906-
// type variables.
10907-
if (i === 0 && argResult.skippedOverloadArg) {
10908-
passCount++;
10909-
}
10903+
if (argResult.isTypeIncomplete) {
10904+
isTypeIncomplete = true;
10905+
}
10906+
10907+
// If we skipped a overload arg during the first pass,
10908+
// add another pass to ensure that we handle all of the
10909+
// type variables.
10910+
if (i === 0 && argResult.skippedOverloadArg) {
10911+
passCount++;
1091010912
}
1091110913
});
10 8B2D 91210914
});

packages/pyright-internal/src/analyzer/typeUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2925,7 +2925,7 @@ class TypeVarTransformer {
29252925
}
29262926

29272927
transformTypeVar(typeVar: TypeVarType, recursionCount: number): Type | undefined {
2928-
return typeVar;
2928+
return undefined;
29292929
}
29302930

29312931
transformTupleTypeVar(paramSpec: TypeVarType, recursionCount: number): TupleTypeArgument[] | undefined {

0 commit comments

Comments
 (0)
0