test/tools/javac/lambda/MethodReference48.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/MethodReference48.java	Wed Apr 27 01:34:52 2016 +0800
     1.3 @@ -0,0 +1,43 @@
     1.4 +/*
     1.5 + * @test /nodynamiccopyright/
     1.6 + * @bug 8003280
     1.7 + * @summary Add lambda tests
     1.8 + *  check that raw qualifier in unbound method reference is inferred from descriptor
     1.9 + * @compile/fail/ref=MethodReference48.out -XDrawDiagnostics MethodReference48.java
    1.10 + */
    1.11 +
    1.12 +public class MethodReference48 {
    1.13 +
    1.14 +    static class Foo<X> {
    1.15 +        X m() { return null; };
    1.16 +    }
    1.17 +
    1.18 +    interface SAM1 {
    1.19 +        Foo<Object> m(Foo<String> fs);
    1.20 +    }
    1.21 +
    1.22 +    interface SAM2 {
    1.23 +        Integer m(Foo<Integer> fi);
    1.24 +    }
    1.25 +
    1.26 +    interface SAM3 {
    1.27 +        Object m(Foo<Integer> fi);
    1.28 +    }
    1.29 +
    1.30 +    static void g1(SAM1 s) { } //return type not compatible
    1.31 +
    1.32 +    static void g2(SAM2 s) { } //ok
    1.33 +
    1.34 +    static void g3(SAM3 s) { } //ok
    1.35 +
    1.36 +    static void g4(SAM1 s) { } //return type not compatible
    1.37 +    static void g4(SAM2 s) { } //ok
    1.38 +    static void g4(SAM3 s) { } //ok
    1.39 +
    1.40 +    public static void main(String[] args) {
    1.41 +        g1(Foo::m);
    1.42 +        g2(Foo::m);
    1.43 +        g3(Foo::m);
    1.44 +        g4(Foo::m);
    1.45 +    }
    1.46 +}

mercurial