From 2ffecb841b078e2952b200ece21d1c2cdad52f9a Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sat, 7 May 2016 13:04:22 +0200 Subject: Fix comments in Eq class and make it a trait. --- src/scala/Eq.scala | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/scala') 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 } -- cgit v1.2.3