diff --git a/mypy/checkmember.py b/mypy/checkmember.py index 08d4ff412e4e0..554b49d3eda21 100644 --- a/mypy/checkmember.py +++ b/mypy/checkmember.py @@ -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: diff --git a/test-data/unit/check-incremental.test b/test-data/unit/check-incremental.test index 5fca0f55a0d66..e5b69fb6fb9d4 100644 --- a/test-data/unit/check-incremental.test +++ b/test-data/unit/check-incremental.test @@ -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]