mirror of
https://github.com/microsoft/pyright.git
synced 2024-09-11 16:06:39 +03:00
Fixed #155: Add missing declared type for "self" or "cls" parameters in methods so the hover provider reports the correct inferred type.
This commit is contained in:
parent
ed4f87a4c9
commit
6c25035b1d
@ -436,22 +436,21 @@ export class TypeAnalyzer extends ParseTreeWalker {
|
||||
parameters.forEach((param, index) => {
|
||||
const paramNode = node.parameters[index];
|
||||
if (paramNode.name) {
|
||||
const specializedParamType = TypeUtils.specializeType(param.type, undefined);
|
||||
|
||||
let declaration: Declaration | undefined;
|
||||
declaration = {
|
||||
category: SymbolCategory.Parameter,
|
||||
node: paramNode,
|
||||
path: this._fileInfo.filePath,
|
||||
range: convertOffsetsToRange(paramNode.start, paramNode.end, this._fileInfo.lines),
|
||||
declaredType: paramNode.typeAnnotation ?
|
||||
TypeUtils.specializeType(param.type, undefined) :
|
||||
undefined
|
||||
declaredType: specializedParamType
|
||||
};
|
||||
assert(paramNode !== undefined && paramNode.name !== undefined);
|
||||
|
||||
// If the type contains type variables, specialize them now
|
||||
// so we convert them to a concrete type (or unknown if there
|
||||
// are is no bound or contraints).
|
||||
const specializedParamType = TypeUtils.specializeType(param.type, undefined);
|
||||
// is no bound or contraint).
|
||||
const variadicParamType = this._getVariadicParamType(param.category, specializedParamType);
|
||||
this._addTypeSourceToNameNode(paramNode.name, variadicParamType, declaration);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user