sdk icon indicating copy to clipboard operation
sdk copied to clipboard

[analyzer][fix] resolve `AddExplicitCast` issues

Open asashour opened this issue 3 years ago • 2 comments

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.

asashour avatar Sep 04 '22 05:09 asashour

https://dart-review.googlesource.com/c/sdk/+/259701

Handling ARGUMENT_TYPE_NOT_ASSIGNABLE

asashour avatar Sep 17 '22 06:09 asashour

https://dart-review.googlesource.com/c/sdk/+/260111

asashour avatar Sep 20 '22 16:09 asashour

https://dart-review.googlesource.com/c/sdk/+/263741

asashour avatar Oct 13 '22 08:10 asashour

sdk/276160 to enable the multi fix.

asashour avatar Dec 16 '22 16:12 asashour

sdk/281380

Previously, .cast<> was added when:

  • from: (iterable or list) to list, or
  • from: (iterable or set) to set.

Now:

  • from: (iterable, list or set) to list, or
  • from: (iterable, list or set) to set

In other words

  • from: (iterable || list ||set) to (list || set)

asashour avatar Feb 07 '23 10:02 asashour