test/tools/javac/lambda/MethodReference45.java

Wed, 27 Apr 2016 01:34:52 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:34:52 +0800
changeset 0
959103a6100f
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/langtools/
changeset: 2573:53ca196be1ae
tag: jdk8u25-b17

     1 /*
     2  * @test /nodynamiccopyright/
     3  * @bug 8003280
     4  * @summary Add lambda tests
     5  *  check that generic method reference is inferred when type parameters are omitted
     6  * @compile/fail/ref=MethodReference45.out -XDrawDiagnostics MethodReference45.java
     7  */
     8 public class MethodReference45 {
    10     static int assertionCount = 0;
    12     static void assertTrue(boolean cond) {
    13         assertionCount++;
    14         if (!cond)
    15             throw new AssertionError();
    16     }
    18     static class SuperFoo<X> { }
    20     static class Foo<X extends Number> extends SuperFoo<X> { }
    22     interface SAM1 {
    23         void m();
    24     }
    26     interface SAM2 {
    27         void m();
    28     }
    30     static <X extends Number> Foo<X> m() { return null; }
    32     static void g1(SAM1 s) { }
    33     static void g2(SAM1 s) { }
    34     static void g2(SAM2 s) { }
    36     void test() {
    37         g1(MethodReference45::m);
    38         g2(MethodReference45::m);
    39     }
    40 }

mercurial