Skip to content

Commit

Permalink
Add test case for fixed bug regarding nested generic classes (#12652)
Browse files Browse the repository at this point in the history
Closes #5551 (the bug in that issue was fixed by #12590)
  • Loading branch information
AlexWaygood authored Apr 22, 2022
1 parent 6eac240 commit 09dbdf6
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test-data/unit/check-generics.test
Original file line number Diff line number Diff line change
Expand Up @@ -1506,6 +1506,22 @@ class Outer(Generic[T]):
def g(self) -> None:
y: T # E: Invalid type "__main__.T"

[case testGenericClassInsideOtherGenericClass]
from typing import TypeVar, Generic
T = TypeVar("T")
K = TypeVar("K")

class C(Generic[T]):
def __init__(self, t: T) -> None: ...
class F(Generic[K]):
def __init__(self, k: K) -> None: ...
def foo(self) -> K: ...

reveal_type(C.F(17).foo()) # N: Revealed type is "builtins.int"
reveal_type(C("").F(17).foo()) # N: Revealed type is "builtins.int"
reveal_type(C.F) # N: Revealed type is "def [K] (k: K`1) -> __main__.C.F[K`1]"
reveal_type(C("").F) # N: Revealed type is "def [K] (k: K`1) -> __main__.C.F[K`1]"


-- Callable subtyping with generic functions
-- -----------------------------------------
Expand Down

0 comments on commit 09dbdf6

Please sign in to comment.