Skip to content

Commit c8fad3f

Browse files
authored
Add missing test case for polymorphic inference (#18626)
1 parent 5ee02cd commit c8fad3f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test-data/unit/check-generics.test

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3035,6 +3035,21 @@ def id(x: V) -> V:
30353035
reveal_type(dec(id, id)) # N: Revealed type is "def [T] (T`1) -> Tuple[T`1, T`1]"
30363036
[builtins fixtures/tuple.pyi]
30373037

3038+
[case testInferenceAgainstGenericSecondary]
3039+
from typing import TypeVar, Callable, List
3040+
3041+
S = TypeVar('S')
3042+
T = TypeVar('T')
3043+
U = TypeVar('U')
3044+
3045+
def dec(f: Callable[[List[T]], List[int]]) -> Callable[[T], T]: ...
3046+
3047+
@dec
3048+
def id(x: U) -> U:
3049+
...
3050+
reveal_type(id) # N: Revealed type is "def (builtins.int) -> builtins.int"
3051+
[builtins fixtures/tuple.pyi]
3052+
30383053
[case testInferenceAgainstGenericEllipsisSelfSpecialCase]
30393054
# flags: --new-type-inference
30403055
from typing import Self, Callable, TypeVar

0 commit comments

Comments
 (0)