Bug in overload disambiguation / inference
Zhong Yu
zhong.j.yu at gmail.com
Sun Feb 23 12:39:32 PST 2014
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