Closed
Description
The analyzer cascade_invocations lint asks for cascading across different references:
test.dart:
class A {
int f;
int g;
}
class B {
final A a = A();
}
void main() {
final B b1 = B();
final B b2 = B();
b1.a
..f = 1
..g = 1;
b2.a.f = 2;
}
With analysis_options.yaml:
linter:
rules:
- cascade_invocations
Gives
$ dartanalyzer ../cascade_bug_test.dart
Analyzing ../cascade_bug_test.dart...
lint • Cascade consecutive method invocations on the same reference at /usr/local/google/home/zra/dart/cascade_bug_test.dart:17:3 • cascade_invocations
1 lint found.
Where line 17 is b2.a.f = 2;
where b2 is a different reference and can't be cascaded with the b1.a
cascade.