"more specific method" w.r.t function return type
Zhong Yu
zhong.j.yu at gmail.com
Tue Dec 17 16:06:45 PST 2013
The following code does not compile in jdk8b120
public class Tmp
{
<T> void foo(Function<String,T> function){}
void foo(Consumer<String> consumer){}
void test()
{
foo( s->System::gc ); // javac: foo is ambiguous
}
}
however I think that foo#1 should be more specific than foo#2, because
Consumer returns void.
Is this a javac bug or my understanding is incorrect?
(If foo#1 is indeed the most specific method, the code still won't
compile because gc() returns void)
Zhong Yu
More information about the lambda-dev
mailing list