See example which works for an array but does not compile for a list.
public class HamcrestLimit {
public void fooArray(String[] arr) {
}
public void fooList(List<String> list) {
}
static void main() {
var mock = Mockito.mock(HamcrestLimit.class);
mock.fooArray(new String[]{"a", "b", "c"});
Mockito.verify(mock).fooArray(MockitoHamcrest.argThat(Matchers.arrayContaining("a", "b", "c"))); // <- fine
mock.fooList(List.of("a","b","c"));
Mockito.verify(mock).fooList(MockitoHamcrest.argThat(Matchers.contains("a", "b", "c"))); // <- does not compile
}
Compilation failure:
HamcrestLimit.java:[25,29] incompatible types: inferred type does not conform to upper bound(s)
[ERROR] inferred: java.lang.Iterable<? extends java.lang.String>
[ERROR] upper bound(s): java.util.List<java.lang.String>,java.lang.Object
Java version: 25.0.1, mockito 5.23.0, hamcrest 3.0
Maybe it duplicates #436
See example which works for an array but does not compile for a list.
Compilation failure:
Java version: 25.0.1, mockito 5.23.0, hamcrest 3.0
Maybe it duplicates #436