Hi guys.
I've faced with strange issue in my java class: eclipse can't compile code
public static void main(String[] args) {
List<Foo> foos = null;
Optional.ofNullable(foos)
.map(list -> list.stream().collect(Collectors.toMap(foo -> foo.getFoo(), foo -> foo)))
.orElse(Collections.emptyMap());
}
private static class Foo {
private String foo;
public String getFoo() {
return foo;
}
}
Compilation error: Type mismatch: cannot convert from Optional<Object> to <unknown>
Without groovy plugin everything compiles fine
As workaround I can define type of foo variable explicitly and everything compiles fine
.map(list -> list.stream().collect(Collectors.toMap((Foo foo) -> foo.getFoo(), foo -> foo)))
My system("fresh" eclipse installation from official site and groovy plugin):
eclipse.buildId=4.6.1.M20160907-1200
java.version=1.8.0_111
java.vendor=Oracle Corporation
Windows7 x64
Hi guys.
I've faced with strange issue in my java class: eclipse can't compile code
Compilation error:
Type mismatch: cannot convert from Optional<Object> to <unknown>Without groovy plugin everything compiles fine
As workaround I can define type of
foovariable explicitly and everything compiles fineMy system("fresh" eclipse installation from official site and groovy plugin):
eclipse.buildId=4.6.1.M20160907-1200
java.version=1.8.0_111
java.vendor=Oracle Corporation
Windows7 x64