You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Mapping.get overload has covariant type as argument #9555
Why is there a covariant variable being used as a function input? Is there any case where this simplified signature would be incompatible with the current signature?
it seems that the issue is that there is a reasonable expectation that for Mapping.get, if _T is a subtype of _VT_co, then the return value should be interpreted as _VT_co. It seems that to do this correctly, some kind of conditional @overload would be required
@randolf-scholz If you want to write an exploratory PR that would certainly be welcome. We have a much better test infrastructure nowadays that allows us to judge the impact of any changes.
Activity
srittau commentedon Jan 17, 2023
This was previously tried in #2810, but then reverted in #2817, which has extensive discussion about this.
randolf-scholz commentedon Jan 17, 2023
@srittau Looking at the example given in the PR
it seems that the issue is that there is a reasonable expectation that for
Mapping.get, if_Tis a subtype of_VT_co, then the return value should be interpreted as_VT_co. It seems that to do this correctly, some kind of conditional@overloadwould be requiredsrittau commentedon Jan 17, 2023
@randolf-scholz If you want to write an exploratory PR that would certainly be welcome. We have a much better test infrastructure nowadays that allows us to judge the impact of any changes.
randolf-scholz commentedon Jan 17, 2023
@srittau I think with the current typing system it's unfortunately impossible. One would need something like TypeScript's Conditional Types