Skip to content

Commit

Permalink
Fixed a bug that results in a spurious error when specializing an old…
Browse files Browse the repository at this point in the history
…-style generic type alias whose type is defined as a new-style type alias that has multiple type parameters, only some of which are used in its type definition. This addresses #9273.
  • Loading branch information
erictraut committed Oct 20, 2024
1 parent 9b0d2e0 commit 0f3a561
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions packages/pyright-internal/src/analyzer/typeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2004,14 +2004,24 @@ export function getTypeVarArgsRecursive(type: Type, recursionCount = 0): TypeVar
recursionCount++;

const aliasInfo = type.props?.typeAliasInfo;
if (aliasInfo?.typeArgs) {
if (aliasInfo) {
const combinedList: TypeVarType[] = [];

aliasInfo?.typeArgs.forEach((typeArg) => {
addTypeVarsToListIfUnique(combinedList, getTypeVarArgsRecursive(typeArg, recursionCount));
});
if (aliasInfo.typeArgs) {
aliasInfo?.typeArgs.forEach((typeArg) => {
addTypeVarsToListIfUnique(combinedList, getTypeVarArgsRecursive(typeArg, recursionCount));
});

return combinedList;
return combinedList;
}

if (aliasInfo.shared.typeParams) {
aliasInfo.shared.typeParams.forEach((typeParam) => {
addTypeVarsToListIfUnique(combinedList, [typeParam]);
});

return combinedList;
}
}

if (isTypeVar(type)) {
Expand Down

0 comments on commit 0f3a561

Please sign in to comment.