Skip to content

Commit b19b899

Browse files
rwbartongvanrossum
authored andcommitted
Add regression tests for a fix mentioned in #1721 (#1750)
1 parent a702c40 commit b19b899

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test-data/unit/check-inference-context.test

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,3 +795,26 @@ class A(Generic[S]):
795795
[builtins fixtures/list.py]
796796
[out]
797797
main: note: In member "f" of class "A":
798+
799+
[case testLambdaInGenericFunction]
800+
from typing import TypeVar, Callable
801+
T = TypeVar('T')
802+
S = TypeVar('S')
803+
def f(a: T, b: S) -> None:
804+
c = lambda x: x # type: Callable[[T], S]
805+
[out]
806+
main: note: In function "f":
807+
main:5: error: Incompatible return value type (got "T", expected "S")
808+
main:5: error: Incompatible types in assignment (expression has type Callable[[T], T], variable has type Callable[[T], S])
809+
810+
[case testLambdaInGenericClass]
811+
from typing import TypeVar, Callable, Generic
812+
T = TypeVar('T')
813+
S = TypeVar('S')
814+
class A(Generic[T]):
815+
def f(self, b: S) -> None:
816+
c = lambda x: x # type: Callable[[T], S]
817+
[out]
818+
main: note: In member "f" of class "A":
819+
main:6: error: Incompatible return value type (got "T", expected "S")
820+
main:6: error: Incompatible types in assignment (expression has type Callable[[T], T], variable has type Callable[[T], S])

0 commit comments

Comments
 (0)