Need better warning message when precedence order causes the error #19478
Labels
analyzer-ux
area-analyzer
Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
P3
A lower priority bug or feature request
type-enhancement
A request for a change that isn't a bug
Given the following code:
class A {
}
class B extends A {
void b() {}
}
f(bool p) {
var v1 = p ? new A() : new B()..b();
var v2 = p ? new A() : (new B()..b());
}
There is a warning on the line defining v1 because the cascade is applied to the result of the conditional operator. But we could notice that the method is defined on the static type of the else-expression and suggest that the problem is the precedence of the cascade operator and that parentheses will fix the problem.
The text was updated successfully, but these errors were encountered: