we want to upgrade from Eclipse Mars to Neon, but our projects do not compile. In Mars, the following code compiles:
public class AmbiguousMWE {
private <T, C extends Collection<T>> void foo(final C c, final Function<T, T> b) {}
private <T> void foo(final T t, final Function<T, T> f) {}
private void test() {
foo(new ArrayList<>(), this::get);
}
private Object get(final Object o) {
return null;
}
private Object get() {
return null;
}
}
If, however, we remove the last get () method, the code does not compile due to the error 'The foo (ArrayList, Function) method is ambiguous for the AmbiguousMWE type'. You can try to change the order of the methods, and you may have different compiler behavior.
And besides, when upgrading to Eclipse Neon, this error always occurs, and there is a lot of source code that no longer compiles.
So, firstly, I don’t know that the second get () method is related to the error, and secondly, what can be done to tell Eclipse to still compile our code?
Thanks for any ideas.