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
Dart analyzer type inference with "is" type check #9666
Comments
This comment was originally written by @bp74 Just tested with the new Dart Analyzer. The test "case 1" doesn't work too. So maybe it's better to write the code in another way anyway. |
The new analyzer does not yet have any type inferencing in it, but will handle "is" when type inferencing is added. Set owner to @bwilkerson. |
This comment was originally written by amouravski@google.com Added Editor-AnalysisEngine label. |
Case 1 is now working. Removed Type-Defect, AnalysisEngine, Editor-AnalysisEngine labels. |
I think I'm hitting the same issue: SwapComponent _getSwap() { Attachment: |
Removed this from the Later milestone. |
Removed Oldschool-Milestone-Later label. |
Cases 1 and 2 are working now. So it's just the |
Closing as stale. |
This issue was originally filed by @bp74
What steps will reproduce the problem?
class foo {
}
class oneFoo extends foo {
bool coolProperty = true;
}
class twoFoo extends foo {
bool coolProperty = true;
}
void main() {
foo f = getFoo();
// case 1:
if (f is oneFoo)
if (f.coolProperty)
print("works fine!");
// case 2:
if (f is oneFoo && f.coolProperty)
print("analyzer warning :(");
// case 3:
if (f is oneFoo || f is twoFoo)
if (f.coolProperty)
print("analyzer warning :(");
}
foo getFoo() {
return new oneFoo();
}
What is the expected output? What do you see instead?
The source above shows three cases, only case 1 works without an analyzer warning.
I think all those cases should be accepted by the analyzer as valid code, especially because case 1 is supported too.
case 2 and case 3 give the warning:
"coolProperty" is not a member of foo
What version of the product are you using? On what operating system?
Dart Editor version 0.1.2_r20908
Dart SDK version 0.1.2.0_r20908
Please provide any additional information below.
The text was updated successfully, but these errors were encountered: