@@ -1091,15 +1091,23 @@ from typing_extensions import Protocol, runtime_checkable
10911091class FnProto(Protocol):
10921092 def __call__(self, x: int, /) -> object: ...
10931093
1094+ class FnImpl:
1095+ def __call__(self, x: object, /) -> int: ...
1096+
10941097def test_object(x: object) -> None:
10951098 match x:
10961099 case FnProto() as fn:
10971100 reveal_type(fn) # N: Revealed type is "__main__.FnProto"
10981101
1099- def test_impl(x: Callable[[int], int] ) -> None:
1102+ def test_impl(x: FnImpl ) -> None:
11001103 match x:
11011104 case FnProto() as fn:
1102- reveal_type(fn) # N: Revealed type is "def (builtins.int) -> builtins.int"
1105+ reveal_type(fn) # N: Revealed type is "__main__.FnImpl"
1106+
1107+ def test_callable(x: Callable[[object], int]) -> None:
1108+ match x:
1109+ case FnProto() as fn:
1110+ reveal_type(fn) # N: Revealed type is "def (builtins.object) -> builtins.int"
11031111
11041112[builtins fixtures/dict.pyi]
11051113
@@ -1111,15 +1119,23 @@ from typing_extensions import Protocol, runtime_checkable
11111119class AnyCallable(Protocol):
11121120 def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
11131121
1122+ class FnImpl:
1123+ def __call__(self, x: object, /) -> int: ...
1124+
11141125def test_object(x: object) -> None:
11151126 match x:
11161127 case AnyCallable() as fn:
11171128 reveal_type(fn) # N: Revealed type is "__main__.AnyCallable"
11181129
1119- def test_impl(x: Callable[[int], int] ) -> None:
1130+ def test_impl(x: FnImpl ) -> None:
11201131 match x:
11211132 case AnyCallable() as fn:
1122- reveal_type(fn) # N: Revealed type is "def (builtins.int) -> builtins.int"
1133+ reveal_type(fn) # N: Revealed type is "__main__.FnImpl"
1134+
1135+ def test_callable(x: Callable[[object], int]) -> None:
1136+ match x:
1137+ case AnyCallable() as fn:
1138+ reveal_type(fn) # N: Revealed type is "def (builtins.object) -> builtins.int"
11231139
11241140[builtins fixtures/dict.pyi]
11251141
0 commit comments