Skip to content

Commit

Permalink
Add test cases for issue #288
Browse files Browse the repository at this point in the history
These pass so it seems that we can close #288.

Apparently the underlying issue was fixed by
commit beff15f.
  • Loading branch information
JukkaL committed Nov 2, 2014
1 parent 9756eb0 commit 3bbba8c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions mypy/test/data/check-generics.test
Original file line number Diff line number Diff line change
Expand Up @@ -802,3 +802,29 @@ g2(f)
def g3(f: Function[[object], object]) -> None: pass
g3(f) # E: Argument 1 to "g3" has incompatible type Function[["T"] -> "T"]; \
expected Function[["object"] -> "object"]


-- Special cases
-- -------------


[case testIdentityHigherOrderFunction]
from typing import Function, typevar
A = typevar('A')
B = typevar('B')
def square(n: int) -> int:
return n
def id(f: Function[[A], B]) -> Function[[A], B]:
return f
g = id(square)
g(1)
g('x') # E: Argument 1 has incompatible type "str"; expected "int"


[case testIdentityHigherOrderFunction2]
from typing import Function, typevar
A = typevar('A')
def voidify(n: int) -> None: pass
def identity(f: Function[[A], None]) -> Function[[A], None]:
return f
identity(voidify)(3)

0 comments on commit 3bbba8c

Please sign in to comment.