While Java 8's type inference seems much improved, I've hit on a possible limitation and I'm not sure if there's some workaround I'm missing. The scenario:
class Foo<T> {
<U> void apply(Function<T, Consumer<U>> bar) {}
}
class Bar {
void setBar(String bar){}
}
Foo<Bar> foo = new Foo<>();
This works:
foo.<String>apply(bar -> bar::setBar);
This does not:
foo.apply(bar -> bar::setBar);
Is there any way to get type inference to work in this sort of situation?
It is an eclipse bug. Both compile fine with Netbeans or javac.
It seems that Eclipse has quite a few issues with java 8...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With