Skip to content

Commit

Permalink
Fix incremental crash on generic function appearing in nested position (
Browse files Browse the repository at this point in the history
#14148)

Fixes #14137 

Fix is trivial, I just forgot to call `super()` in one of my previous
PRs.
  • Loading branch information
ilevkivskyi authored Nov 19, 2022
1 parent 56e9396 commit e814c47
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions mypy/checkmember.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,7 @@ class FreezeTypeVarsVisitor(TypeTraverserVisitor):
def visit_callable_type(self, t: CallableType) -> None:
for v in t.variables:
v.id.meta_level = 0
super().visit_callable_type(t)


def lookup_member_var_or_accessor(info: TypeInfo, name: str, is_lvalue: bool) -> SymbolNode | None:
Expand Down
14 changes: 14 additions & 0 deletions test-data/unit/check-incremental.test
Original file line number Diff line number Diff line change
Expand Up @@ -6334,3 +6334,17 @@ reveal_type(D().meth)
[out2]
tmp/m.py:4: note: Revealed type is "def [Self <: lib.C] (self: Self`0, other: Self`0) -> Self`0"
tmp/m.py:5: note: Revealed type is "def (other: m.D) -> m.D"

[case testIncrementalNestedGenericCallableCrash]
from typing import TypeVar, Callable

T = TypeVar("T")

class B:
def foo(self) -> Callable[[T], T]: ...

class C(B):
def __init__(self) -> None:
self.x = self.foo()
[out]
[out2]

0 comments on commit e814c47

Please sign in to comment.