Incorrect "Incompatible return type Object in lambda expression"

Using Intellij 13.1.4 and Java 8

Given the source code:

package my.foobar;

import java.util.concurrent.ConcurrentMap;

import lombok.ToString;

public class FooBar {

    public static class Foo {
        private String foo;
        private String bar;

        public Foo(String foo, String bar) {
   = foo;
   = bar;

        public String getFoo() {
            return foo;

        public void setFoo(String foo) {
   = foo;

        public String getBar() {
            return bar;

        public void setBar(String bar) {
   = bar;

    public static void main(String[] args) {
        final ImmutableList<Foo> foos = ImmutableList.of(new Foo("a", "b"), new Foo("b", "c"));
        final ConcurrentMap<Foo, ImmutableSet<String>> map =
                        it -> it, // Incorrect "Incompatible return type Object in lambda expression" error
                        it -> ImmutableSet.of(it.getBar()),
                        (a, b) -> ImmutableSet.<String>builder().addAll(a).addAll(b).build()
        System.out.println("map = " + map); // the error appears not immediatelly, but after writing some more code, after the lambda expression is written

which compiles, runs and produces output:

map = {FooBar.Foo(foo=b, bar=c)=[c], FooBar.Foo(foo=a, bar=b)=[b]}

But Intellij shows an errror at

it -> it

1 comment
Comment actions Permalink


is fixed in 14 EAP, unfortunately EAP suffers from  

Sorry for the inconvenience


Please sign in to leave a comment.