Open
Description
See this code.
from typing import TypeVar
T = TypeVar("T", list, dict)
def ctor(cls: type[T]) -> T:
return cls()
def ctor_union(cls: type[list] | type[dict]) -> list | dict:
return cls()
def ctor_union_proxy(cls: type[list] | type[dict]) -> list | dict:
return ctor(cls)
produces
main.py:12: error: Value of type variable "T" of "ctor" cannot be "Collection[Any]" [type-var]
main.py:12: error: Incompatible return value type (got "Collection[Any]", expected "list[Any] | dict[Any, Any]") [return-value]
Found 2 errors in 1 file (checked 1 source file)
possibly duplicate of #9424.