-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make prefer_collection_literals
less suggestive for sets
#57905
Comments
Mulling over a few concrete examples final Set<RenderObject> hits = LinkedHashSet<RenderObject>(); final List<String> where = Set<String>.from(skipped).toList()..sort(); (and a few related), I'd like to drop the flagging of:
@bwilkerson: I think these were the kinds of cases you maybe anticipated in your earlier review? Any other thoughts? |
If you want to peruse any more of the failures yourself, here's the failing run: https://ci.chromium.org/p/dart/builders/luci.dart.try/flutter-analyze-try/26 |
I'm not sure why. As I understand it, a set literal creates an instance of
I think the assist only works for |
Sorry, I should have shared more of my thinking. It's because of cases like this: that provoke an error like: error: The set literal type 'Set<String>' isn't of expected type 'HashSet<String>'. The set's type can be changed with an explicit generic type argument or by changing the element types. (strong_mode_invalid_cast_literal_set at ...) For a first cut I think missing cases like this: Set<String> s = new HashSet<String>(); which I do think should be potentially flagged is OK. But then maybe it's alright that folks need to address the type error above after applying an assist?
Aha. Right. I had this logic as I recall and then talked myself out of needing it. Can't recall now why though... 🤔 |
I would say no. Our policy on assists has always been that if the code was valid before applying an assist it should be valid after. If the assist can produce invalid code then we should capture the reproduction case (in an issue, or better as a failing test) and fix the bug. |
The initial implementation flags lots of places in the flutter repo that would be tricky to migrate. I'd like to review and relax before trying to push the updated lint.
(Note that this gates integration into the SDK.)
The text was updated successfully, but these errors were encountered: