DeepCollectionEquality is not symmetric most of the time
When comparing a List/Set to an Iterable, the order of the arguments will give a different result, making them non-symmetric.
This actually varies on the implementation though - in the case of DeepCollectionEquality.unordered then the results are symmetric, but only when comparing specifically a List and an Iterable 😱 .
Fixing this would be breaking at this point. Some options available to us are:
- Change the behavior and do a breaking change.
- Change the behavior but consider it as a bug fix and don't do a breaking change.
- Deprecate existing constructors, add new ones that behave in a more sane (or at least consistent) manner.
- Add new constructors that behave consistently, leave old ones in place and don't deprecate.
- Do nothing.
cc @natebosch @lrhn
See the tests in the linked pr (https://github.com/dart-lang/collection/pull/209) which demonstrate the behavior.
I think I would be in favor of writing a symmetric CollectionEquality and deprecating DeepCollectionEquality.
I am not sure that CollectionEquality implies deep equality though? Unless we wanted to make whether it uses deep equality a configurable thing?