Currently, equalTo() will not compile when comparing Object to another class forcing unnecessary casting. For example:
HttpServletRequest request = (get request);
Object actual = request.getAttribute("SomeAttribute");
assertThat(actual, equalTo((Object) fooInstance));
In this example, the compile will fail unless fooInstance is cast to Object. But this is unnecessary for equals() to work correctly.
If the signature of equalsTo() were:
Matcher<Object> equalTo(Object o)
it could avoid the above problem.
Currently,
equalTo()will not compile when comparingObjectto another class forcing unnecessary casting. For example:HttpServletRequest request = (get request);Object actual = request.getAttribute("SomeAttribute");assertThat(actual, equalTo((Object) fooInstance));In this example, the compile will fail unless
fooInstanceis cast toObject. But this is unnecessary forequals()to work correctly.If the signature of
equalsTo()were:Matcher<Object> equalTo(Object o)it could avoid the above problem.