test/tools/javac/lambda/MethodReference28.java

Tue, 12 Mar 2013 16:02:43 +0000

author
mcimadamore
date
Tue, 12 Mar 2013 16:02:43 +0000
changeset 1628
5ddecb91d843
parent 0
959103a6100f
permissions
-rw-r--r--

8009545: Graph inference: dependencies between inference variables should be set during incorporation
Summary: Move all transitivity checks into the incorporation round
Reviewed-by: jjg

     1 /*
     2  * @test /nodynamiccopyright/
     3  * @bug 8003280
     4  * @summary Add lambda tests
     5  *  check that non-compatible method references are rejected
     6  * @compile/fail/ref=MethodReference28.out -XDrawDiagnostics MethodReference28.java
     7  */
     9 class MethodReference28 {
    11     interface SAM1 {
    12         void m(int i);
    13     }
    15     interface SAM2 {
    16         void m(MethodReference28 rec, int i);
    17     }
    19     static void static_m1(Integer i) { } //ok - boxing
    20     static void static_m2(Integer i1, Integer i2) { } //wrong arity
    21     static void static_m3(String s) { } //type mismatch
    22     static void static_m4(String... ss) { } //type mismatch - varargs
    24     void m1(Integer i) { } //ok - boxing
    25     void m2(Integer i1, Integer i2) { } //wrong arity
    26     void m3(String s) { } //type mismatch
    27     void m4(String... ss) { } //type mismatch - varargs
    29     static void testStatic() {
    30         SAM1 s1 = MethodReference28::static_m1;
    31         SAM1 s2 = MethodReference28::static_m2;
    32         SAM1 s3 = MethodReference28::static_m3;
    33         SAM1 s4 = MethodReference28::static_m4;
    34     }
    36     void testBadMember() {
    37         SAM1 s1 = MethodReference28::m1;
    38         SAM1 s2 = MethodReference28::m2;
    39         SAM1 s3 = MethodReference28::m3;
    40         SAM1 s4 = MethodReference28::m4;
    41     }
    43     void testMember() {
    44         SAM1 s1 = this::m1;
    45         SAM1 s2 = this::m2;
    46         SAM1 s3 = this::m3;
    47         SAM1 s4 = this::m4;
    48     }
    50     static void testUnbound() {
    51         SAM2 s1 = MethodReference28::m1;
    52         SAM2 s2 = MethodReference28::m2;
    53         SAM2 s3 = MethodReference28::m3;
    54         SAM2 s4 = MethodReference28::m4;
    55     }
    56 }

mercurial