diff --git a/packages/pyright-internal/src/analyzer/properties.ts b/packages/pyright-internal/src/analyzer/properties.ts index be6536b63..a55fa483f 100644 --- a/packages/pyright-internal/src/analyzer/properties.ts +++ b/packages/pyright-internal/src/analyzer/properties.ts @@ -121,6 +121,14 @@ export function clonePropertyWithSetter( if (!isProperty(prop)) { return prop; } + // this is safe. see comment on isProperty + prop = prop as ClassType; + + // if it's an abstract property, mark the parameter as accessed + if (prop.priv?.fgetInfo?.methodType && FunctionType.isAbstractMethod(prop.priv.fgetInfo.methodType)) { + // first parameter is self, there should only ever be one other parameter. + evaluator.markParamAccessed(errorNode.d.params[1]); + } const classType = prop as ClassType; const flagsToClone = classType.shared.flags; diff --git a/packages/pyright-internal/src/analyzer/typeEvaluator.ts b/packages/pyright-internal/src/analyzer/typeEvaluator.ts index ca4f8bf7e..7549202eb 100644 --- a/packages/pyright-internal/src/analyzer/typeEvaluator.ts +++ b/packages/pyright-internal/src/analyzer/typeEvaluator.ts @@ -28434,6 +28434,7 @@ export function createTypeEvaluator( checkForCancellation, printControlFlowGraph, typesOverlap, + markParamAccessed, }; const codeFlowEngine = getCodeFlowEngine(evaluatorInterface, speculativeTypeTracker); diff --git a/packages/pyright-internal/src/analyzer/typeEvaluatorTypes.ts b/packages/pyright-internal/src/analyzer/typeEvaluatorTypes.ts index fc3a7fae1..4ff0b7a83 100644 --- a/packages/pyright-internal/src/analyzer/typeEvaluatorTypes.ts +++ b/packages/pyright-internal/src/analyzer/typeEvaluatorTypes.ts @@ -884,4 +884,5 @@ export interface TypeEvaluator { logger: ConsoleInterface ) => void; typesOverlap: (leftType: Type, rightType: Type, checkEq: boolean) => boolean; + markParamAccessed: (param: ParameterNode) => void; } diff --git a/packages/pyright-internal/src/analyzer/typeUtils.ts b/packages/pyright-internal/src/analyzer/typeUtils.ts index 2b889e441..26d5d6cf8 100644 --- a/packages/pyright-internal/src/analyzer/typeUtils.ts +++ b/packages/pyright-internal/src/analyzer/typeUtils.ts @@ -1423,7 +1423,8 @@ export function isEllipsisType(type: Type): boolean { return isAny(type) && type.priv.isEllipsis; } -export function isProperty(type: Type) { +// type guard commented out due to https://github.com/microsoft/TypeScript/issues/15048 +export function isProperty(type: Type) /* : type is ClassType */ { return isClassInstance(type) && ClassType.isPropertyClass(type); }