The hasItem matcher has the signature
Matcher<Iterable<? super T>> hasItem(Matcher<? super T> itemMatcher)
but it should be
Matcher<Iterable<? extends T>> hasItem(Matcher<? super T> itemMatcher)
because the matcher needs to read items from the Iterable and it needs the contract that the sequence contains at least items of type T, so it should be covariant in T
The current implementation states the opposite, it would be applicable it the matcher wanted to write to the iterable, but that is (a) not possible, since there is no write operation on an iterable and (b) not its usecase.
The
hasItemmatcher has the signaturebut it should be
because the matcher needs to read items from the
Iterableand it needs the contract that the sequence contains at least items of typeT, so it should be covariant inTThe current implementation states the opposite, it would be applicable it the matcher wanted to write to the iterable, but that is (a) not possible, since there is no write operation on an iterable and (b) not its usecase.