mirror of
https://github.com/microsoft/pyright.git
synced 2024-09-11 07:55:56 +03:00
Fixed regression in the handling of certain __init__
methods with an explicit type annotation for self
.
This commit is contained in:
parent
add2193101
commit
d34d9ccc27
@ -27006,7 +27006,14 @@ export function createTypeEvaluator(
|
|||||||
|
|
||||||
const specializedFunction = applySolvedTypeVars(memberType, typeVarContext) as FunctionType;
|
const specializedFunction = applySolvedTypeVars(memberType, typeVarContext) as FunctionType;
|
||||||
|
|
||||||
return FunctionType.clone(specializedFunction, stripFirstParam, baseType, getTypeVarScopeId(baseType));
|
// If this is a constructor method, provide the base type's TypeVar scope ID
|
||||||
|
// so any TypeVars in this type can be solved.
|
||||||
|
let baseTypeTypeVarScopeId: TypeVarScopeId | undefined;
|
||||||
|
if (FunctionType.isConstructorMethod(specializedFunction) || specializedFunction.details.name === '__init__') {
|
||||||
|
baseTypeTypeVarScopeId = getTypeVarScopeId(baseType);
|
||||||
|
}
|
||||||
|
|
||||||
|
return FunctionType.clone(specializedFunction, stripFirstParam, baseType, baseTypeTypeVarScopeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isFinalVariable(symbol: Symbol): boolean {
|
function isFinalVariable(symbol: Symbol): boolean {
|
||||||
|
@ -1658,10 +1658,7 @@ export namespace FunctionType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
newFunction.inferredReturnType = type.inferredReturnType;
|
newFunction.inferredReturnType = type.inferredReturnType;
|
||||||
|
newFunction.boundTypeVarScopeId = boundTypeVarScopeId ?? type.boundTypeVarScopeId;
|
||||||
if (newFunction.preBoundFlags & FunctionTypeFlags.ConstructorMethod) {
|
|
||||||
newFunction.boundTypeVarScopeId = boundTypeVarScopeId ?? type.boundTypeVarScopeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
return newFunction;
|
return newFunction;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user