Ambiguity method error when one method can't be applicable

Anna Kozlova Anna.Kozlova at jetbrains.com
Tue Oct 8 08:52:35 PDT 2013


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