-
Notifications
You must be signed in to change notification settings - Fork 379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hasEntry matcher needs proper variance declarations #107
Comments
Actually |
Agree - The The 'contains ' method returns |
I looked at this a bit closer. As far as I can tell by the commit history, this was fixed in 2008, when the signature of the I've added a test to |
This fix PECS rule (producer extends, consumer super) to the Hamcrest IsIterableContaining matcher, as well as dependant implementations. In this instance, a collection of items should be treated as a producer according to this rule, while a matcher acts as a consumer. There is also an extra test for type variance in hasEntry (#107) Closes #252
The return type of the hasEntry matcher is invariant on its type parameters which prevents javac/jdt from inferring compatible types. This prevents writing
instead, you have to write
or
If the signature for hasEntry were instead
the original example would work fine. This same problem likely applies to other collection matchers like hasItem, hasKey, etc.
Copied from https://code.google.com/p/hamcrest/issues/detail?id=103
The text was updated successfully, but these errors were encountered: