Open FMorschel opened 1 month ago
I'm not sure that this is the same, but I've also seen:
final email = (user.email != null) ? (user.email!) : '';
This is a dumb example, but my point is that in other ternary expressions that I've used, I saw this.
I think that the (user.email!)
expression should trigger this as well. I'm not sure because this might be intentional to leave ternary expressions with possible parentheses around all possible results.
If you agree that this is also another false-negative I can create another issue.
This is a false negative that occurs in any of the three places of a ternary operator.
Describe the issue
unnecessary_parenthesis
false negative.When having a code like:
The return of
case 0
warns:A value of type 'Object?' can't be returned from the function 'a' because it has a return type of 'T'
.So in that case, we need to wrap that in parentheses.
This doesn't throw anymore.
When changing to the new pattern switch syntax, we can cast at the end as follows:
And now that is not needed anymore and should trigger the lint.