test/tools/javac/lambda/MethodReference47.java

changeset 1415
01c9d4161882
child 2000
4a6acc42c3a1
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/tools/javac/lambda/MethodReference47.java	Sat Nov 17 19:01:03 2012 +0000
     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=MethodReference47.out -XDrawDiagnostics MethodReference47.java
    1.10 + */
    1.11 +public class MethodReference47 {
    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 +    interface SAM1 {
    1.22 +       void m(Integer s);
    1.23 +    }
    1.24 +
    1.25 +    interface SAM2 {
    1.26 +       void m(Integer s);
    1.27 +    }
    1.28 +
    1.29 +    static class Foo<X extends Number> {
    1.30 +        Foo(X x) { }
    1.31 +    }
    1.32 +
    1.33 +    static <X extends Number> void m(X fx) { }
    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 +    public static void main(String[] args) {
    1.40 +        g1(MethodReference46::m);
    1.41 +        g2(MethodReference46::m);
    1.42 +    }
    1.43 +}

mercurial