test/tools/javac/lambda/MethodReference44.java

changeset 0
959103a6100f
child 2525
2eb010b6cb22
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/tools/javac/lambda/MethodReference44.java	Wed Apr 27 01:34:52 2016 +0800
     1.3 @@ -0,0 +1,45 @@
     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=MethodReference44.out -XDrawDiagnostics MethodReference44.java
    1.10 + */
    1.11 +
    1.12 +public class MethodReference44 {
    1.13 +
    1.14 +    static class SuperFoo<X> { }
    1.15 +
    1.16 +    static class Foo<X extends Number> extends SuperFoo<X> { }
    1.17 +
    1.18 +    interface SAM1 {
    1.19 +        SuperFoo<String> m();
    1.20 +    }
    1.21 +
    1.22 +    interface SAM2 {
    1.23 +        SuperFoo<Integer> m();
    1.24 +    }
    1.25 +
    1.26 +    interface SAM3 {
    1.27 +        SuperFoo<Object> m();
    1.28 +    }
    1.29 +
    1.30 +    static <X extends Number> Foo<X> m() { return null; }
    1.31 +
    1.32 +    static void g1(SAM1 s) { }
    1.33 +
    1.34 +    static void g2(SAM2 s) { }
    1.35 +
    1.36 +    static void g3(SAM3 s) { }
    1.37 +
    1.38 +    static void g4(SAM1 s) { }
    1.39 +    static void g4(SAM2 s) { }
    1.40 +    static void g4(SAM3 s) { }
    1.41 +
    1.42 +    public static void main(String[] args) {
    1.43 +        g1(MethodReference44::m);
    1.44 +        g2(MethodReference44::m);
    1.45 +        g3(MethodReference44::m);
    1.46 +        g4(MethodReference44::m);
    1.47 +    }
    1.48 +}

mercurial