"more specific method" w.r.t function return type
Vicente-Arturo Romero-Zaldivar
vicente.romero at oracle.com
Thu Dec 19 04:47:45 PST 2013
Hi Zhong Yu,
There is a bug report to track this issue,
https://bugs.openjdk.java.net/browse/JDK-8029718. I have added this test
case to it.
Thanks,
Vicente
On 18/12/13 00:16, Zhong Yu wrote:
> On Tue, Dec 17, 2013 at 6:06 PM, Zhong Yu <zhong.j.yu at gmail.com> wrote:
>> 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
> sorry, what I meant was
>
> 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