Make DefaultEquality<Null> work at runtime (#73)
Works around dart-lang/sdk#32415
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c0c429b..b676ee1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,13 @@
+## 1.14.6
+
+* Make `DefaultEquality`'s `equals()` and `hash()` methods take any `Object`
+ rather than objects of type `E`. This makes `const DefaultEquality<Null>()`
+ usable as `Equality<E>` for any `E`, which means it can be used in a const
+ context which expects `Equality<E>`.
+
+ This makes the default arguments of various other const equality constructors
+ work in strong mode.
+
## 1.14.5
* Fix issue with `EmptyUnmodifiableSet`'s stubs that were introduced in 1.14.4.
diff --git a/lib/src/equality.dart b/lib/src/equality.dart
index be7162b..855503e 100644
--- a/lib/src/equality.dart
+++ b/lib/src/equality.dart
@@ -76,10 +76,14 @@
///
/// This equality uses the objects' own [Object.==] and [Object.hashCode] for
/// the equality.
+///
+/// Note that [equals] and [hash] take `Object`s rather than `E`s. This allows
+/// `E` to be inferred as `Null` in const contexts where `E` wouldn't be a
+/// compile-time constant, while still allowing the class to be used at runtime.
class DefaultEquality<E> implements Equality<E> {
const DefaultEquality();
- bool equals(E e1, E e2) => e1 == e2;
- int hash(E e) => e.hashCode;
+ bool equals(Object e1, Object e2) => e1 == e2;
+ int hash(Object e) => e.hashCode;
bool isValidKey(Object o) => true;
}
diff --git a/pubspec.yaml b/pubspec.yaml
index bf07d60..e97a358 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: collection
-version: 1.14.5
+version: 1.14.6
author: Dart Team <misc@dartlang.org>
description: Collections and utilities functions and classes related to collections.
homepage: https://www.github.com/dart-lang/collection