From 08d57abb15c49730fee18a74a42f95bd3526f51a Mon Sep 17 00:00:00 2001 From: Ivan Levkivskyi Date: Thu, 6 Feb 2025 23:51:42 +0000 Subject: [PATCH] Add missing test case for polymorphic inference --- test-data/unit/check-generics.test | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test-data/unit/check-generics.test b/test-data/unit/check-generics.test index 5d6ad8e19631..767b55efcac2 100644 --- a/test-data/unit/check-generics.test +++ b/test-data/unit/check-generics.test @@ -3035,6 +3035,21 @@ def id(x: V) -> V: reveal_type(dec(id, id)) # N: Revealed type is "def [T] (T`1) -> Tuple[T`1, T`1]" [builtins fixtures/tuple.pyi] +[case testInferenceAgainstGenericSecondary] +from typing import TypeVar, Callable, List + +S = TypeVar('S') +T = TypeVar('T') +U = TypeVar('U') + +def dec(f: Callable[[List[T]], List[int]]) -> Callable[[T], T]: ... + +@dec +def id(x: U) -> U: + ... +reveal_type(id) # N: Revealed type is "def (builtins.int) -> builtins.int" +[builtins fixtures/tuple.pyi] + [case testInferenceAgainstGenericEllipsisSelfSpecialCase] # flags: --new-type-inference from typing import Self, Callable, TypeVar