For this code:
class Test {
static <U> Iterable<U> map(Mapper<String, U> mapper) {
return null;
}
static void test() {
Iterable<Integer> map = map(Test::length);
}
public static <T> int length(String s) {
return 0;
}
}
interface Mapper<T, U> {
U map(T t);
}
javac generates this error message:
Test.java:7: error: incompatible types: inference variable U has incompatible bounds
Iterable<Integer> map = map(Test::length);
^
equality constraints: Integer
lower bounds: Integer,int <--- primitive type in bound
where U is a type-variable:
U extends Object declared in method <U>map(Mapper<String,U>)
1 error
reported by anna.kozlova_at_jetbrains.com in compiler-dev