aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/scala/Eq.scala11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/scala/Eq.scala b/src/scala/Eq.scala
index 6d993ac39..1ac6e55d2 100644
--- a/src/scala/Eq.scala
+++ b/src/scala/Eq.scala
@@ -2,9 +2,9 @@ package scala
import annotation.implicitNotFound
-/** A marker class indicating that values of kind `T` can be compared. */
+/** A marker trait indicating that values of kind `T` can be compared to values of type `U`. */
@implicitNotFound("Values of types ${L} and ${R} cannot be compared with == or !=")
-class Eq[-L, -R]
+trait Eq[-L, -R]
/** Besides being a companion object, this object
* can also be used as a value that's compatible with
@@ -12,8 +12,11 @@ class Eq[-L, -R]
*/
object Eq extends Eq[Any, Any] {
- /** An implicit that provides an `Eq` instance for all types `T`
- * such that `T <: EqClass[T]`.
+ /** A fall-back implicit to compare values of any types.
+ * The compiler will restrict implicit instances of `eqAny`. An instance
+ * `eqAny[T, U]` is _invalid_ if `T` or `U` is a non-bottom type that
+ * has an implicit `Eq[T, T]` (respectively `Eq[U, U]`) instance.
+ * An implicit search will fail instead of returning an invalid `eqAny` instance,
*/
implicit def eqAny[L, R]: Eq[L, R] = Eq
}