-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
bugSomething isn't workingSomething isn't workingtyMulti-file analysis & type inferenceMulti-file analysis & type inference
Milestone
Description
class C:
def f(self):
self.x: int = 1
def g[T](self, t: T) -> T:
self.y: str = "foo"
return t
reveal_type(C().x) # correctly reveals `int`
reveal_type(C().y) # should reveal `str`, but instead errors with `unresolved-attribute`Generic functions have an additional type-params scope in between the outer scope and the function body scope. SemanticIndexBuilder::is_method_of_class fails to account for this, so we fail to record attribute assignments that occur in a generic method.
Relatedly, we now have "is this function a method of a class" logic separately both in SemanticIndexBuilder::is_method_of_class and in TypeInferenceBuilder::infer_function_body (as part of detecting whether a function is a method of a protocol). It may be worth seeing if we can unify that logic to a single location (maybe a method on Scope?).
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingtyMulti-file analysis & type inferenceMulti-file analysis & type inference