Ambiguity method error when one method can't be applicable

Anna Kozlova Anna.Kozlova at jetbrains.com
Tue Oct 8 11:02:30 PDT 2013


This worked for me with the latest build from the 'lambda' repository but
fails as I've described with b.109 from https://jdk8.java.net/download.html.

Thank you
Anna Kozlova
JetBrains
http://www.jetbrains.com
"Develop with pleasure!" 

 

-----Original Message-----
From: lambda-dev-bounces at openjdk.java.net
[mailto:lambda-dev-bounces at openjdk.java.net] On Behalf Of Samir Talwar
Sent: Tuesday, October 08, 2013 6:18 PM
To: Anna Kozlova
Cc: lambda-dev
Subject: Re: Ambiguity method error when one method can't be applicable

This works well for me in the Early Access release. It calls `static void
m(I2)`.

It compiled and run as-is, but produced no output. I added behaviour to the
static `m` methods in order to verify it was doing as expected. My code is
here: http://pastebin.com/0iYFW40T .

- Samir.


On Tue, Oct 8, 2013 at 4:52 PM, Anna Kozlova
<Anna.Kozlova at jetbrains.com>wrote:

> Hi guys,
>
>
>
> The following code does not compile with ambiguous method error:
>
>
>
> class MyTest {
>
>
>
>     interface I1 {
>
>         Foo<Number> m(String s);
>
>     }
>
>
>
>     interface I2 {
>
>         Foo<Number> m(Integer i);
>
>     }
>
>
>
>     static class Foo<T extends Number> {
>
>         Foo(T t) {
>
>             System.out.println(t);
>
>         }
>
>     }
>
>
>
>     private static void m(I1 i) {}
>
>     private static void m(I2 i) {}
>
>
>
>     public static void main(String[] args) {
>
>         m(Foo::new);
>
>     }
>
> }
>
>
>
> Some time ago though there was no such an error.
>
>
>
> Not sure that I understand why compiler can't resolve such an 
> ambiguity for me. Could someone explain, please?
>
>
>
> Thank you
> Anna Kozlova
> JetBrains
>  <http://www.intellij.com/> http://www.jetbrains.com "Develop with 
> pleasure!"
>
>
>
>
>


!DSPAM:35,5254309831851748229832!



More information about the lambda-dev mailing list