Skip to content

Commit bbf99b7

Browse files
authored
* revert etorreborre#1112 https://github.com/etorreborre/specs2/pull/1112/files This causes beEqualTo usages with vague types to fail compilation. * added a test * fix formatting * fix formatting 2 * fix compilation * CR * format * small fix
1 parent 76e79ac commit bbf99b7

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

matcher/shared/src/main/scala/org/specs2/matcher/AnyMatchers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class BeFalseMatcher extends Matcher[Boolean]:
176176

177177
/** Equality Matcher
178178
*/
179-
class BeEqualTo[T](t: =>T) extends EqualityMatcher(t)
179+
class BeEqualTo(t: =>Any) extends EqualityMatcher(t)
180180

181181
/** This matcher always matches any value of type T
182182
*/

tests/shared/src/test/scala/org/specs2/matcher/BeEqualToMatcherSpec.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ class BeEqualToMatcherSpec extends Spec with ResultMatchers with ShouldMatchers
3535
${"a" must be_!=("b")}
3636
${"a" must not(be_!=("a"))}
3737

38+
Distinguish between typed and non typed equality matchers
39+
${A must be_==("a")}
40+
Will not compile: {A must not be_===("a")}
41+
3842
Array equality uses deep array comparison, with or without typed equality
3943
${Array(1, 2) must be_==(Array(1, 2))}
4044
${Array(1, 2) must be_==(Array(1, 2))}
@@ -122,3 +126,7 @@ Details
122126
}
123127

124128
case class Hello() { override def toString = "hello" }
129+
130+
object A {
131+
override def equals(that: Any) = that == "a"
132+
}

0 commit comments

Comments
 (0)