-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Overloaded Union Return Types #3652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It's a good question. See #1805. There's been talk of implementing a special case for this, but I haven't seen it yet. |
It's actually not quite related to that @nycdotnet. It's actually in the spec. From 6.1 Function Declarations:
This leaves me wondering whether there's a better way to do this or if we need to reconsider this rule in the spec. |
Hmm... That does feel reversed. Obviously the use case is that having determined which override is being invoked, the implementation is contracting to return that type, thereby not requiring further type disambiguqtion by the consumer. |
See #943 |
Yup, it is a duplicate of #943. I will take a look there. |
Stupid question of the day, why does this not work:
Where as this is valid:
I am allowed to "delegate" the sorting out of the typing of my argument to my overloaded function implementation, but, I am not allowed to delegate the return type, though I am contracting to only return to return a certain type of return value (which is what I am doing with the handling arguments). Is there a good reason I am missing?
The text was updated successfully, but these errors were encountered: