saisaripalli / hamcrest

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

javac compilation problem #82

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I started using hamcrest 1.2 a few days ago and i am really happy about it.
Today i run compilation of test classes in maven and to my surprise these
do not compile!.
For example trying to compile the following code:
Assert.assertThat(3, either(comparesEqualTo(4)).or(comparesEqualTo(3)));

i got compilation error:
or(org.hamcrest.Matcher<? super java.lang.Object>) in
org.hamcrest.core.CombinableMatcher<java.lang.Object> cannot be applied to
(org.hamcrest.Matcher<ca
pture of ? super java.lang.Integer>)
                Assert.assertThat(3,
either(comparesEqualTo(4)).or(comparesEqualTo(3)));

I found a post on John Ferguson blog
(http://weblogs.java.net/blog/johnsmart/archive/2008/04/on_the_subtle_u.html)
and on its basis I was able to create a workaround:
CombinableMatcher<Integer> either = either(comparesEqualTo(4));
Assert.assertThat(4, either.or(comparesEqualTo(3)));

Unfortunately this make my tests clumsy and unreadable. 

1. I am wondering why this code compile in Eclipse and not outside eclipse
(by execution javac, ant or maven) ?
2. Can anything can be done about it ?

Original issue reported on code.google.com by jmilkiew...@gmail.com on 27 May 2009 at 4:39