diff --git a/matcher/shared/src/main/scala/org/specs2/matcher/AnyMatchers.scala b/matcher/shared/src/main/scala/org/specs2/matcher/AnyMatchers.scala index 9e3abfc330..cd45f74bbd 100644 --- a/matcher/shared/src/main/scala/org/specs2/matcher/AnyMatchers.scala +++ b/matcher/shared/src/main/scala/org/specs2/matcher/AnyMatchers.scala @@ -176,7 +176,7 @@ class BeFalseMatcher extends Matcher[Boolean]: /** Equality Matcher */ -class BeEqualTo[T](t: =>T) extends EqualityMatcher(t) +class BeEqualTo(t: =>Any) extends EqualityMatcher(t) /** This matcher always matches any value of type T */ diff --git a/tests/shared/src/test/scala/org/specs2/matcher/BeEqualToMatcherSpec.scala b/tests/shared/src/test/scala/org/specs2/matcher/BeEqualToMatcherSpec.scala index 97170a2004..3ae62d0d1b 100644 --- a/tests/shared/src/test/scala/org/specs2/matcher/BeEqualToMatcherSpec.scala +++ b/tests/shared/src/test/scala/org/specs2/matcher/BeEqualToMatcherSpec.scala @@ -35,6 +35,10 @@ class BeEqualToMatcherSpec extends Spec with ResultMatchers with ShouldMatchers ${"a" must be_!=("b")} ${"a" must not(be_!=("a"))} + Distinguish between typed and non typed equality matchers + ${A must be_==("a")} + Will not compile: {A must not be_===("a")} + Array equality uses deep array comparison, with or without typed equality ${Array(1, 2) must be_==(Array(1, 2))} ${Array(1, 2) must be_==(Array(1, 2))} @@ -122,3 +126,7 @@ Details } case class Hello() { override def toString = "hello" } + +object A { + override def equals(that: Any) = that == "a" +}