Bug in overload disambiguation / inference

Vicente-Arturo Romero-Zaldivar vicente.romero at oracle.com
Mon Jul 21 15:05:43 UTC 2014


Hi Sam,

The bug you reported [1] has been fixed in 8udev repo [2]. Thanks again 
for your report.

Vicente

[1] https://bugs.openjdk.java.net/browse/JDK-8035761
[2] http://hg.openjdk.java.net/jdk8u/jdk8u-dev/langtools

On 02/25/2014 11:30 AM, Vicente-Arturo Romero-Zaldivar wrote:
> Hi,
>
> We are just modifying this part of the compiler, bug entry:
> https://bugs.openjdk.java.net/browse/JDK-8029718
> So the compiler's output for some of these examples may change. I will
> modify the bug entry to track also this test case.
>
> The assertion error is probably a separate bug, I have filed bug entry
> https://bugs.openjdk.java.net/browse/JDK-8035761, to track it.
>
> Thanks,
> Vicente
>
> On 23/02/14 20:39, Zhong Yu wrote:
>> Note that this line doesn't compile either:
>>
>>       run( (O t)->{ throw new Exception(); });
>>
>> I think this line is not supposed to compile (though javac apparently
>> gives the wrong error message).
>>
>> Zhong Yu
>>
>>
>> On Sun, Feb 23, 2014 at 12:31 PM, Sam Pullara <spullara at gmail.com> wrote:
>>> The issues center around some overloads that the library has:
>>>
>>>       interface Function<T, V> extends PartialFunction<T, V> {
>>>         V apply(T paramT);
>>>       }
>>>
>>>       interface PartialFunction<T, V> {
>>>         V apply(T paramT) throws Exception;
>>>       }
>>>
>>>       interface O {}
>>>
>>>       static <T, V> void run(Function<? super O, V> function) {}
>>>       static <T, V> void run(PartialFunction<? super O, V> function) {}
>>>
>>> (full code here: https://gist.github.com/spullara/9175196)
>>>
>>> Calling the method like this:
>>>
>>> run(t -> t.toString())
>>>
>>> causes an assertion error in the compiler (b129). I'm assuming that is just
>>> a bug. The problem I run into is when you call it like:
>>>
>>> run((O t) -> t.toString())
>>>
>>> which results in
>>>
>>> java: reference to run is ambiguous
>>>     both method <T,V>run(spullara.ExceptionInferenceBug.Function<? super
>>> spullara.ExceptionInferenceBug.O,V>) in spullara.ExceptionInferenceBug and
>>> method <T,V>run(spullara.ExceptionInferenceBug.PartialFunction<? super
>>> spullara.ExceptionInferenceBug.O,V>) in spullara.ExceptionInferenceBug match
>>>
>>> However, if the run methods are defined as:
>>>
>>>       static <T, V> void run(Function<O, V> function) {}
>>>       static <T, V> void run(PartialFunction<O, V> function) {}
>>>
>>> It works fine. Any ideas? Seems like the same rules should apply.
>>>
>>> Sam
>>>
>



More information about the lambda-dev mailing list