Ambiguity method error when one method can't be applicable

Samir Talwar samir at noodlesandwich.com
Tue Oct 8 09:17:46 PDT 2013


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!"
>
>
>
>
>


More information about the lambda-dev mailing list