linter
linter copied to clipboard
False positive for unnecessary_parenthesis: extension on nullable type
The line with the (*) below causes info: Unnecessary use of parentheses. (unnecessary_parenthesis at line 1
, but without parenthesis around foo?.items
it's a syntax error.
Iterable<int> bar(Foo? foo) => (foo?.items).orEmptyWhenNull; // *
class Foo {
const Foo(this.items);
final List<int> items;
}
extension IterableOrEmptyWhenNull<T> on Iterable<T>? {
Iterable<T> get orEmptyWhenNull => this ?? Iterable<T>.empty();
}
Dart SDK version: 3.0.0 (stable) (Thu May 4 01:11:00 2023 -0700) on "macos_arm64"
(No warning was generated with the previous Dart version, 2.19.6
)
@oprypin: curious if this is related to your recent changes?
I confirm this finding.
https://github.com/dart-lang/linter/commit/823ea6c8e79b61d51141d50bfa86e2d4a714f921 is the first bad commit.
It's about having an extension on nullable. The code of the lint can detect built-in methods like (nullable).hashCode
, but makes no attempt to detect (nullable).extensionMethod
.
Just wanted to chime in that while our team loves this linter rule, we're planning to disable it since applying the quickfix has the potential to introduce bugs into our app, which is frankly outright dangerous for a quickfix.
Fixed by https://github.com/dart-lang/sdk/commit/6c071d3148ddc8aa2226e859ea6650fc8b020c6a