File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
crates/ty_python_semantic/resources/mdtest/generics Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -466,6 +466,7 @@ wrong_innards: C[int] = C("five", 1)
466466from typing_extensions import overload, Generic, TypeVar
467467
468468T = TypeVar(" T" )
469+ U = TypeVar(" U" )
469470
470471class C (Generic[T]):
471472 @overload
@@ -497,6 +498,17 @@ C[int](12)
497498C[None ](" string" ) # error: [no-matching-overload]
498499C[None ](b " bytes" ) # error: [no-matching-overload]
499500C[None ](12 )
501+
502+ class D (Generic[T, U]):
503+ @overload
504+ def __init__ (self : " D[str, U]" , u : U) -> None : ...
505+ @overload
506+ def __init__ (self , t : T, u : U) -> None : ...
507+ def __init__ (self , * args ) -> None : ...
508+
509+ reveal_type(D(" string" )) # revealed: D[str, str]
510+ reveal_type(D(1 )) # revealed: D[str, int]
511+ reveal_type(D(1 , " string" )) # revealed: D[int, str]
500512```
501513
502514### Synthesized methods with dataclasses
Original file line number Diff line number Diff line change @@ -436,6 +436,17 @@ C[int](12)
436436C[None ](" string" ) # error: [no-matching-overload]
437437C[None ](b " bytes" ) # error: [no-matching-overload]
438438C[None ](12 )
439+
440+ class D[T, U]:
441+ @overload
442+ def __init__ (self : " D[str, U]" , u : U) -> None : ...
443+ @overload
444+ def __init__ (self , t : T, u : U) -> None : ...
445+ def __init__ (self , * args ) -> None : ...
446+
447+ reveal_type(D(" string" )) # revealed: D[str, str]
448+ reveal_type(D(1 )) # revealed: D[str, int]
449+ reveal_type(D(1 , " string" )) # revealed: D[int, str]
439450```
440451
441452### Synthesized methods with dataclasses
You can’t perform that action at this time.
0 commit comments