test/tools/javac/lambda/MethodReference68.java

changeset 1897
866c87c01285
parent 0
959103a6100f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/tools/javac/lambda/MethodReference68.java	Wed Jul 17 14:09:46 2013 +0100
     1.3 @@ -0,0 +1,23 @@
     1.4 +/*
     1.5 + * @test /nodynamiccopyright/
     1.6 + * @bug 8016175
     1.7 + * @summary Add bottom-up type-checking support for unambiguous method references
     1.8 + * @compile/fail/ref=MethodReference68.out -XDrawDiagnostics MethodReference68.java
     1.9 + */
    1.10 +class MethodReference68 {
    1.11 +    interface F<X> {
    1.12 +       String m(X x);
    1.13 +    }
    1.14 +
    1.15 +    static class Foo {
    1.16 +        String getName() { return ""; }
    1.17 +    }
    1.18 +
    1.19 +    @SuppressWarnings("unchecked")
    1.20 +    <Z> void g(F<Z> fz, Z... zs) { }
    1.21 +
    1.22 +    void test() {
    1.23 +         g(Foo::getName);
    1.24 +         g(Foo::getName, 1); //incompatible constraints, Z <: Foo, Z :> Integer
    1.25 +    }
    1.26 +}

mercurial