import java.util.Collection; import java.util.List; import java.util.function.Consumer; class A { public A(){} public A(Collection x, Consumer y) {} public void failToCompile(Consumer x) {} public A add(A x) { return this; } public void fail(Collection x) { A builder = new A<>(); builder.add(new A<>(x, A::notify)) .failToCompile(A::notify); builder.failToCompile(A::notify); } } abstract class B { abstract List add(B b); abstract B create(List l, Consumer c); void f(List l, B b) { String o = add(create(l, (t) -> t.hashCode())).get(0);//fails to compile in java 8, compiles in java 9, 10 String o1 = add(create(l, (t) -> {})).get(0); String o2 = add(b).get(0); } }