Open
Description
@Hixie commented on Mar 4, 2018, 10:53 AM UTC:
Enable the cascade_invocations lint, then analyze this:
class A { }
class B extends A { void foo() { } }
void test(A x) {
if (A is B) {
final B b = x;
b.foo();
}
}
void main() { }
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:
class A { }
class B extends A { void foo() { } }
void test(A x) {
if (A is B) {
final B b = x
..foo();
}
}
void main() { }
...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.
Metadata
Metadata
Assignees
Labels
A lower priority bug or feature requestFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.Issues with the analyzer's support for the linter packageIssues related to lint rules that report a problem when it isn't a problem.Incorrect behavior (everything from a crash to more subtle misbehavior)