sdk
sdk copied to clipboard
[analyzer][fix] resolve `AddExplicitCast` issues
In AddExplicitCast correction:
- [ ] there are 5 TODOs
- [ ] 10 of the tests are failing because they require enabling FixInFile in 10 tests (related to #45026).
- [ ] In
test_assignment_list()
f(List<A> a) {
List<B> b;
b = a.where((e) => e is B).toList();
print(b);
}
class A {}
class B {}
The fix generates
b = a.where((e) => e is B).cast<B>().toList();
which then suggests fixing prefer_iterable_whereType
To be finally
b = a.whereType<B>().cast<B>().toList();
The correction should directly produce the last code.
https://dart-review.googlesource.com/c/sdk/+/259701
Handling ARGUMENT_TYPE_NOT_ASSIGNABLE
https://dart-review.googlesource.com/c/sdk/+/260111
https://dart-review.googlesource.com/c/sdk/+/263741
sdk/276160 to enable the multi fix.
Previously, .cast<> was added when:
- from: (
iterableorlist) tolist, or - from: (
iterableorset) toset.
Now:
- from: (
iterable,listorset) tolist, or - from: (
iterable,listorset) toset
In other words
- from: (
iterable||list||set) to (list||set)