Type inference restrictions with lambda expressions

While output like Java 8 seems much improved, I hit a possible limitation, and I'm not sure if there is any workaround that I am missing. Scenario:

class Foo<T> { <U> void apply(Function<T, Consumer<U>> bar) {} } class Bar { void setBar(String bar){} } Foo<Bar> foo = new Foo<>(); 

It works:

 foo.<String>apply(bar -> bar::setBar); 

It does not mean:

 foo.apply(bar -> bar::setBar); 

Is there a way to get type inference to work in a similar situation?

+7
java lambda java-8 type-inference
source share
1 answer

This is an eclipse error. Both are compiled using Netbeans or javac.

It seems that Eclipse has quite a few issues with java 8 ...

+6
source share

All Articles