thrown types cannot be inferred from lambda body because of cyclic inference
Thomas Jung
thomas.andreas.jung at googlemail.com
Sat Oct 30 09:39:38 PDT 2010
Hi,
the following does not compile:
import com.google.common.base.*;
class X{
private Predicate<Integer> x = new Predicate<Integer>(){
public boolean apply(Integer v) { return v % 3 == 0; }
};
Predicate<Integer> y = #{Integer v -> v % 3 == 0 };
Predicate<Integer> z = #{v -> v % 3 == 0 }; //does not compile
}
X.java:11: warning: thrown types cannot be inferred from lambda body
because of cyclic inference
Predicate<Integer> z = #{v -> v % 3 == 0 }; //does not compile
^
explicit type required for the following parameter: v
1 warning
The error message is a bit strange. I can't see a cycle. Could someone
explain it?
Thomas
More information about the lambda-dev
mailing list