test/tools/javac/lambda/MethodReference45.java

changeset 0
959103a6100f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/tools/javac/lambda/MethodReference45.java	Wed Apr 27 01:34:52 2016 +0800
     1.3 @@ -0,0 +1,40 @@
     1.4 +/*
     1.5 + * @test /nodynamiccopyright/
     1.6 + * @bug 8003280
     1.7 + * @summary Add lambda tests
     1.8 + *  check that generic method reference is inferred when type parameters are omitted
     1.9 + * @compile/fail/ref=MethodReference45.out -XDrawDiagnostics MethodReference45.java
    1.10 + */
    1.11 +public class MethodReference45 {
    1.12 +
    1.13 +    static int assertionCount = 0;
    1.14 +
    1.15 +    static void assertTrue(boolean cond) {
    1.16 +        assertionCount++;
    1.17 +        if (!cond)
    1.18 +            throw new AssertionError();
    1.19 +    }
    1.20 +
    1.21 +    static class SuperFoo<X> { }
    1.22 +
    1.23 +    static class Foo<X extends Number> extends SuperFoo<X> { }
    1.24 +
    1.25 +    interface SAM1 {
    1.26 +        void m();
    1.27 +    }
    1.28 +
    1.29 +    interface SAM2 {
    1.30 +        void m();
    1.31 +    }
    1.32 +
    1.33 +    static <X extends Number> Foo<X> m() { return null; }
    1.34 +
    1.35 +    static void g1(SAM1 s) { }
    1.36 +    static void g2(SAM1 s) { }
    1.37 +    static void g2(SAM2 s) { }
    1.38 +
    1.39 +    void test() {
    1.40 +        g1(MethodReference45::m);
    1.41 +        g2(MethodReference45::m);
    1.42 +    }
    1.43 +}

mercurial