test/tools/javac/lambda/MethodReference51.java

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

author
mcimadamore
date
Tue, 12 Mar 2013 16:02:43 +0000
changeset 1628
5ddecb91d843
parent 1415
01c9d4161882
child 2193
d4cbb671de1c
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  *  certain cases of erroneous member reference lookup are not handled by Attr.visitReference
     6  * @compile/fail/ref=MethodReference51.out -XDrawDiagnostics MethodReference51.java
     7  */
     8 class MethodReference51 {
    10     private static class Foo {
    11         static int j(int i) { return i; }
    12     }
    14     static Foo foo = new Foo();
    16     static void m(String s) { }
    17     static void m(Integer i) { }
    19     static int f(String s) { return 1; }
    21     static int g(Integer i, Number n) { return 1; }
    22     static int g(Number n, Integer i) { return 1; }
    24     int h(int i) { return i; }
    25 }
    27 class TestMethodReference51 {
    29     interface IntSam {
    30         int m(int i);
    31     }
    33     interface IntegerIntegerSam {
    34         int m(Integer i1, Integer i2);
    35     }
    38     static void test() {
    39         IntSam s1 = MethodReference51::unknown; //method not found
    40         IntSam s2 = MethodReference51::f; //inapplicable method
    41         IntSam s3 = MethodReference51::g; //inapplicable methods
    42         IntegerIntegerSam s4 = MethodReference51::g; //ambiguous
    43         IntSam s5 = MethodReference51::h; //static error
    44         IntSam s6 = MethodReference51.foo::j; //inaccessible method
    45     }
    46 }

mercurial