Skip to content
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

Return type restriction on NilableCast (as?) #14498

Open
straight-shoota opened this issue Apr 16, 2024 · 0 comments
Open

Return type restriction on NilableCast (as?) #14498

straight-shoota opened this issue Apr 16, 2024 · 0 comments

Comments

@straight-shoota
Copy link
Member

I noticed that the return type of x.as?(T) is always T | Nil.
In some cases however, could be further reduced. This could allow removal of some code paths that would never be reached anyway.

  • If typeof(x) <= T, the result is always T.
  • If typeof(x) has no intersection with Y, the result is always Nil.

I don't see any particular reason why the return type should not be restricted as much as possible, but maybe I'm missing something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant