diff --git a/packages/pyright-internal/src/analyzer/properties.ts b/packages/pyright-internal/src/analyzer/properties.ts index be6536b63638..da8345912a10 100644 --- a/packages/pyright-internal/src/analyzer/properties.ts +++ b/packages/pyright-internal/src/analyzer/properties.ts @@ -134,7 +134,7 @@ export function clonePropertyWithSetter( const typeAnnotation = getTypeAnnotationForParam(errorNode, 1); if (typeAnnotation) { // Verify consistency of the type. - const fgetType = evaluator.getGetterTypeFromProperty(classType, /* inferTypeIfNeeded */ false); + const fgetType = evaluator.getGetterTypeFromProperty(classType); if (fgetType && !isAnyOrUnknown(fgetType)) { const fsetType = evaluator.getTypeOfAnnotation(typeAnnotation, { typeVarGetsCurScope: true, diff --git a/packages/pyright-internal/src/analyzer/protocols.ts b/packages/pyright-internal/src/analyzer/protocols.ts index 4c908c193cd6..173f04afa818 100644 --- a/packages/pyright-internal/src/analyzer/protocols.ts +++ b/packages/pyright-internal/src/analyzer/protocols.ts @@ -654,7 +654,7 @@ function assignToProtocolInternal( } } else { // Extract the property type from the property class. - let getterType = evaluator.getGetterTypeFromProperty(destMemberType, /* inferTypeIfNeeded */ true); + let getterType = evaluator.getGetterTypeFromProperty(destMemberType); if (getterType) { getterType = partiallySpecializeType(getterType, mroClass, evaluator.getTypeClassType()); diff --git a/packages/pyright-internal/src/analyzer/typeEvaluator.ts b/packages/pyright-internal/src/analyzer/typeEvaluator.ts index 1936924ea68b..dfb3a548448b 100644 --- a/packages/pyright-internal/src/analyzer/typeEvaluator.ts +++ b/packages/pyright-internal/src/analyzer/typeEvaluator.ts @@ -445,7 +445,6 @@ interface ValidateArgTypeOptions { interface EffectiveReturnTypeOptions { callSiteInfo?: CallSiteEvaluationInfo; - skipInferReturnType?: boolean; } interface SignatureTrackerStackEntry { @@ -23030,11 +23029,7 @@ export function createTypeEvaluator( return specializedReturnType; } - if (!options?.skipInferReturnType) { - return getInferredReturnType(type, options?.callSiteInfo); - } - - return UnknownType.create(); + return getInferredReturnType(type, options?.callSiteInfo); } function _getInferredReturnType(type: FunctionType, callSiteInfo?: CallSiteEvaluationInfo) { @@ -23950,7 +23945,7 @@ export function createTypeEvaluator( return true; } - function getGetterTypeFromProperty(propertyClass: ClassType, inferTypeIfNeeded: boolean): Type | undefined { + function getGetterTypeFromProperty(propertyClass: ClassType): Type | undefined { if (!ClassType.isPropertyClass(propertyClass)) { return undefined; } diff --git a/packages/pyright-internal/src/analyzer/typeEvaluatorTypes.ts b/packages/pyright-internal/src/analyzer/typeEvaluatorTypes.ts index a2137df86599..69fc859642b4 100644 --- a/packages/pyright-internal/src/analyzer/typeEvaluatorTypes.ts +++ b/packages/pyright-internal/src/analyzer/typeEvaluatorTypes.ts @@ -697,7 +697,7 @@ export interface TypeEvaluator { errorNode: ExpressionNode, emitNotIterableError?: boolean ) => TypeResult | undefined; - getGetterTypeFromProperty: (propertyClass: ClassType, inferTypeIfNeeded: boolean) => Type | undefined; + getGetterTypeFromProperty: (propertyClass: ClassType) => Type | undefined; getTypeOfArg: (arg: Arg, inferenceContext: InferenceContext | undefined) => TypeResult; convertNodeToArg: (node: ArgumentNode) => ArgWithExpression; buildTupleTypesList: (entryTypeResults: TypeResult[], stripLiterals: boolean) => TupleTypeArg[]; diff --git a/packages/pyright-internal/src/analyzer/types.ts b/packages/pyright-internal/src/analyzer/types.ts index e14e736af735..f003f256b40d 100644 --- a/packages/pyright-internal/src/analyzer/types.ts +++ b/packages/pyright-internal/src/analyzer/types.ts @@ -1728,7 +1728,7 @@ export namespace FunctionType { } export function createSynthesizedInstance(name: string, additionalFlags = FunctionTypeFlags.None) { - return create(name, '', '', additionalFlags | FunctionTypeFlags.SynthesizedMethod, TypeFlags.Instance); + return create(name, name, '', additionalFlags | FunctionTypeFlags.SynthesizedMethod, TypeFlags.Instance); } function create( diff --git a/packages/pyright-internal/src/languageService/completionProviderUtils.ts b/packages/pyright-internal/src/languageService/completionProviderUtils.ts index 5887a3f6f08d..4b9315fa637b 100644 --- a/packages/pyright-internal/src/languageService/completionProviderUtils.ts +++ b/packages/pyright-internal/src/languageService/completionProviderUtils.ts @@ -122,8 +122,7 @@ export function getTypeDetail( if (isProperty(functionType) && detail?.boundObjectOrClass && isClassInstance(detail.boundObjectOrClass)) { const propertyType = - evaluator.getGetterTypeFromProperty(functionType as ClassType, /* inferTypeIfNeeded */ true) || - UnknownType.create(); + evaluator.getGetterTypeFromProperty(functionType as ClassType) || UnknownType.create(); return name + ': ' + evaluator.printType(propertyType) + ' (property)'; }