different TODO explanation for overload example

This commit is contained in:
Douglas Creager 2025-12-05 16:33:29 -05:00
parent b84a35f22f
commit a372e63b2c
1 changed files with 8 additions and 3 deletions

View File

@ -658,13 +658,18 @@ class ClassWithOverloadedInit[T]:
def __init__(self: "ClassWithOverloadedInit[str]", x: str) -> None: ... def __init__(self: "ClassWithOverloadedInit[str]", x: str) -> None: ...
def __init__(self, x: int | str) -> None: ... def __init__(self, x: int | str) -> None: ...
# TODO: These unions are because we don't handle the ParamSpec in accepts_callable, so when # TODO: The old solver cannot handle this overloaded constructor. The ideal solution is that we
# inferring a specialization through the Callable we lose the information about how the parameter # would solve **P once, and map it to the entire overloaded signature of the constructor. This
# types distinguish the two overloads. # mapping would have to include the return types, since there are different return types for each
# overload. We would then also have to determine that R must be equal to the return type of **P's
# solution.
# TODO: revealed: ClassWithOverloadedInit[int] # TODO: revealed: ClassWithOverloadedInit[int]
# revealed: ClassWithOverloadedInit[int] | ClassWithOverloadedInit[str] # revealed: ClassWithOverloadedInit[int] | ClassWithOverloadedInit[str]
reveal_type(accepts_callable(ClassWithOverloadedInit)(0)) reveal_type(accepts_callable(ClassWithOverloadedInit)(0))
# TODO: revealed: ClassWithOverloadedInit[str] # TODO: revealed: ClassWithOverloadedInit[str]
# TODO: no [invalid-argument-type]
# error: [invalid-argument-type]
# revealed: ClassWithOverloadedInit[int] | ClassWithOverloadedInit[str] # revealed: ClassWithOverloadedInit[int] | ClassWithOverloadedInit[str]
reveal_type(accepts_callable(ClassWithOverloadedInit)("")) reveal_type(accepts_callable(ClassWithOverloadedInit)(""))