Moe Sync by ronshapiro · Pull Request #575 · google/truth
OK, trying again: Truth-that-requires-T would still fail on the cartesianProduct example, even under a new javac. The error is now:
core/src/test/java/com/google/common/truth/IterableSubjectTest.java:56: error: method containsExactly in class IterableSubject<E> cannot be applied to given types;
.containsExactly(exp1, exp2, exp3, exp4);
^
required: List<INT#1>[]
found: List<Object>,List<Object>,List<Object>,List<Object>
reason: varargs mismatch; List<Object> cannot be converted to List<INT#1>
where E is a type-variable:
E extends Object declared in class IterableSubject
where INT#1,INT#2 are intersection types:
INT#1 extends Object,Serializable,Comparable<? extends INT#2>
INT#2 extends Object,Serializable,Comparable<?>
And, as a digression here into something else relevant to my interests, the error message is just slightly longer if IterableSubject has self-type and actual-type parameters:
core/src/test/java/com/google/common/truth/IterableSubjectTest.java:56: error: method containsExactly in class IterableSubject<S,A,E> cannot be applied to given types;
.containsExactly(exp1, exp2, exp3, exp4);
^
required: List<INT#1>[]
found: List<Object>,List<Object>,List<Object>,List<Object>
reason: varargs mismatch; List<Object> cannot be converted to List<INT#1>
where S,A,E are type-variables:
S extends IterableSubject<S,A,E> declared in class IterableSubject
A extends Iterable<E> declared in class IterableSubject
E extends Object declared in class IterableSubject
where INT#1,INT#2 are intersection types:
INT#1 extends Object,Serializable,Comparable<? extends INT#2>
INT#2 extends Object,Serializable,Comparable<?>
[edit years later: One case in which it's easy to see how the looser types are useful is if your input is a List<?>.]