-
Notifications
You must be signed in to change notification settings - Fork 1.7k
cascade_invocations is too eager when type promotion is necessary #57970
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
@lrhn commented on Mar 6, 2018, 10:40 AM UTC: Probably don't mean to say |
@Hixie commented on Mar 6, 2018, 7:10 PM UTC: Oops, sorry about that typo. I don't think it changes this bug, though. That conditional could be anything that happens to imply, in a way the analyzer can't recognize, that the cast is ok; the cascade operator isn't appropriate in this case. |
@bwilkerson commented on Mar 6, 2018, 7:17 PM UTC: I'm having trouble thinking of a concrete example of the condition you described. I'm assuming that you actually ran into this somewhere. Can you point us at the actual code that caused the problem? |
@Hixie commented on Mar 6, 2018, 8:34 PM UTC: |
@bwilkerson commented on Mar 6, 2018, 9:01 PM UTC: Ok, thanks. The problem arrises when the variable cannot be promoted. Sounds like the lint might be checking the wrong type at that point. |
@bwilkerson commented on Mar 14, 2018, 2:15 PM UTC: |
@leafpetersen commented on Mar 15, 2018, 1:01 AM UTC: The second error message is actually incorrect, see #30542 The intention is that
should be treated (after implicit downcast insertion) as:
Neither of the front ends implements this entirely yet though. |
(An example of where you might run into this is where the condition is checking runtimeType instead of using |
Friendly asking, has this been fixed, or is the lint still breaking sometimes? |
@Hixie commented on Mar 4, 2018, 10:53 AM UTC:
Enable the cascade_invocations lint, then analyze this:
It says:
lint • Cascade consecutive method invocations on the same reference at test.dart:7:5 • cascade_invocations
However, if you change it as suggested:
...then now the code is no longer correct (
error • The method 'foo' isn't defined for the class 'A' at test.dart:7:9 • undefined_method
).This issue was moved by pq from dart-lang/sdk#32407.
The text was updated successfully, but these errors were encountered: