@@ -2260,3 +2260,40 @@ class Check:
22602260reveal_type(Check.foo()) # N: Revealed type is "def () -> __main__.Check"
22612261reveal_type(Check().foo()) # N: Revealed type is "__main__.Check"
22622262[builtins fixtures/tuple.pyi]
2263+
2264+ [case testSelfInClassmethodWithOtherSelfMethod]
2265+ from typing import Any, Callable, Self, TypeVar
2266+
2267+ _C = TypeVar("_C", bound=Callable[..., Any])
2268+
2269+ def identity(func: _C, /) -> _C:
2270+ return func
2271+
2272+ class A:
2273+ def meth(self) -> Self: ...
2274+
2275+ @classmethod
2276+ def other_meth(cls) -> Self:
2277+ reveal_type(cls.meth) # N: Revealed type is "def [Self <: __main__.A] (self: Self`1) -> Self`1"
2278+ reveal_type(A.meth) # N: Revealed type is "def [Self <: __main__.A] (self: Self`2) -> Self`2"
2279+ return cls().meth()
2280+
2281+ class B:
2282+ @identity
2283+ def meth(self) -> Self: ...
2284+
2285+ @classmethod
2286+ def other_meth(cls) -> Self:
2287+ reveal_type(cls.meth) # N: Revealed type is "def [Self <: __main__.B] (self: Self`6) -> Self`6"
2288+ reveal_type(B.meth) # N: Revealed type is "def [Self <: __main__.B] (self: Self`7) -> Self`7"
2289+ return cls().meth()
2290+
2291+ class C:
2292+ @classmethod
2293+ def other_meth(cls) -> Self: ...
2294+
2295+ def meth(self) -> Self:
2296+ reveal_type(self.other_meth) # N: Revealed type is "def () -> Self`0"
2297+ reveal_type(type(self).other_meth) # N: Revealed type is "def () -> Self`0"
2298+ return self.other_meth()
2299+ [builtins fixtures/tuple.pyi]
0 commit comments