langtools/test/tools/javac/lambda/MethodReference45.java
author mcimadamore
Tue, 12 Mar 2013 16:02:13 +0000
changeset 16340 3c0af3413e0f
parent 14547 86d8d242b0c4
permissions -rw-r--r--
8008540: Constructor reference to non-reifiable array should be rejected 8008539: Spurious error when constructor reference mention an interface type 8008538: Constructor reference accepts wildcard parameterized types Summary: Overhaul of Check.checkConstructorRefType Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14547
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
     1
/*
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
     2
 * @test /nodynamiccopyright/
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
     3
 * @bug 8003280
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
     4
 * @summary Add lambda tests
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
     5
 *  check that generic method reference is inferred when type parameters are omitted
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
     6
 * @compile/fail/ref=MethodReference45.out -XDrawDiagnostics MethodReference45.java
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
     7
 */
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
     8
public class MethodReference45 {
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
     9
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    10
    static int assertionCount = 0;
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    11
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    12
    static void assertTrue(boolean cond) {
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    13
        assertionCount++;
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    14
        if (!cond)
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    15
            throw new AssertionError();
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    16
    }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    17
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    18
    static class SuperFoo<X> { }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    19
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    20
    static class Foo<X extends Number> extends SuperFoo<X> { }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    21
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    22
    interface SAM1 {
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    23
        void m();
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    24
    }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    25
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    26
    interface SAM2 {
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    27
        void m();
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    28
    }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    29
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    30
    static <X extends Number> Foo<X> m() { return null; }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    31
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    32
    static void g1(SAM1 s) { }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    33
    static void g2(SAM1 s) { }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    34
    static void g2(SAM2 s) { }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    35
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    36
    void test() {
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    37
        g1(MethodReference45::m);
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    38
        g2(MethodReference45::m);
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    39
    }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    40
}