arashja / hamcrest

Automatically exported from code.google.com/p/hamcrest
0 stars 0 forks source link

Multiple argument versions of AnyOf.anyOf() are never called, compiler warning still present #129

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
This issue is minor considering tests using org.hamcrest.core.AnyOf complete as 
expected, but causes headaches if you are trying to resolve all compiler 
warnings in your code. It looks as if there is a bug in the multiple argument 
versions of anyOf() that prevents them from ever being called. Instead, the 
varargs version is always called and the compiler warning that was targeted in 
r258 is still present. 

The fix is simple (I think). The first input parameter for each of the multiple 
argument versions of anyOf() should be changed from "Matcher<T> first" to 
"Matcher<? super T> first". This change will allow the multiple argument 
versions to be called and will prevent the compiler warning when between 2 and 
6 input arguments are used.

Original issue reported on code.google.com by bill.bau...@gmail.com on 21 Oct 2010 at 4:48

GoogleCodeExporter commented 8 years ago
The point of "fixing" the type of the first argument is help the compiler find 
a type for the matcher. If it were all <? super T> then various dependencies in 
JMock won't work. Can you just control which code your compiler warnings apply 
to?

Original comment by smgfree...@gmail.com on 28 Apr 2012 at 11:49