-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
No type inference from is!
#35019
Comments
This looks like it is ~mostly covered by @munificent's #29624, which has stalled for quite some time. @mit-mit does it make sense to try and file some tracking issue(s) in
An |
This is a thing that we are aware of and want to address at some point in the future. If we introduce non-nullable types, we will need non-null promotion as well, so revisiting type promotion at that point seems reasonable. As Matan says, you can't use |
@lrhn Is there a language issue tracking the need for better type promotion? |
Better type promotion is useful even without non-nullable types, so I think it's good to keep in mind that we can do earlier if we want. |
I realize that |
Moving this over to: dart-lang/language#80 |
The following code is accepted without error:
However, if I invert the
d is Derived
check:then I get an error:
(The same thing happens if I try
!(d is Derived)
.)This seems inconsistent. Couldn't we internally invert
is!
and theif
-else
clauses to achieve the same behavior as the first version?(And if anyone is wondering why I don't just always use the first version, there are cases where one path has much more code than the other, and for readability I prefer to have the simpler block first, e.g.:
Of course, in that particular case, it be even nicer if:
worked.)
The text was updated successfully, but these errors were encountered: