langtools/test/tools/javac/lambda/TargetType60.java
author vromero
Fri, 15 Nov 2013 11:08:12 +0000
changeset 21718 74a5882faf79
parent 16323 c4409c235642
permissions -rw-r--r--
8026231: Look at 'static' flag when checking method references Reviewed-by: jjg, dlsmith
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16294
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
     1
/*
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
     2
 * @test /nodynamiccopyright/
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
     3
 * @bug 8007462
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
     4
 * @summary Fix provisional applicability for method references
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
     5
 * @compile/fail/ref=TargetType60.out -XDrawDiagnostics TargetType60.java
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
     6
 */
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
     7
class TargetType60 {
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
     8
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
     9
    interface Sam0 {
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    10
        void m();
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    11
    }
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    12
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    13
    interface Sam1<X> {
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    14
        void m(X x);
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    15
    }
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    16
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    17
    interface Sam2<X,Y> {
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    18
        void m(X x, Y y);
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    19
    }
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    20
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    21
    void m0() { }
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    22
    void m1(String s) { }
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    23
    void m2(String s1, String s2) { }
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    24
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    25
    void m01() { }
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    26
    void m01(String s) { }
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    27
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    28
    void m012() { }
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    29
    void m012(String s) { }
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    30
    void m012(String s1, String s2) { }
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    31
16323
c4409c235642 8008537: Missing method reference lookup error when unbound search finds a static method
mcimadamore
parents: 16294
diff changeset
    32
    void n0() { }
c4409c235642 8008537: Missing method reference lookup error when unbound search finds a static method
mcimadamore
parents: 16294
diff changeset
    33
    void n1(String s) { }
c4409c235642 8008537: Missing method reference lookup error when unbound search finds a static method
mcimadamore
parents: 16294
diff changeset
    34
    void n2(TargetType60 rec, String s2) { }
c4409c235642 8008537: Missing method reference lookup error when unbound search finds a static method
mcimadamore
parents: 16294
diff changeset
    35
c4409c235642 8008537: Missing method reference lookup error when unbound search finds a static method
mcimadamore
parents: 16294
diff changeset
    36
    void n01() { }
c4409c235642 8008537: Missing method reference lookup error when unbound search finds a static method
mcimadamore
parents: 16294
diff changeset
    37
    void n01(String s) { }
c4409c235642 8008537: Missing method reference lookup error when unbound search finds a static method
mcimadamore
parents: 16294
diff changeset
    38
c4409c235642 8008537: Missing method reference lookup error when unbound search finds a static method
mcimadamore
parents: 16294
diff changeset
    39
    void n012() { }
c4409c235642 8008537: Missing method reference lookup error when unbound search finds a static method
mcimadamore
parents: 16294
diff changeset
    40
    void n012(String s) { }
c4409c235642 8008537: Missing method reference lookup error when unbound search finds a static method
mcimadamore
parents: 16294
diff changeset
    41
    void n012(TargetType60 rec, String s2) { }
c4409c235642 8008537: Missing method reference lookup error when unbound search finds a static method
mcimadamore
parents: 16294
diff changeset
    42
16294
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    43
    static String g(Sam0 s) { return null; }
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    44
    static <U> U g(Sam1<U> s) { return null; }
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    45
    static <U> U g(Sam2<U,String> s) { return null; }
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    46
16323
c4409c235642 8008537: Missing method reference lookup error when unbound search finds a static method
mcimadamore
parents: 16294
diff changeset
    47
    static <U> U u(Sam1<U> s) { return null; }
c4409c235642 8008537: Missing method reference lookup error when unbound search finds a static method
mcimadamore
parents: 16294
diff changeset
    48
    static <U> U u(Sam2<U,String> s) { return null; }
c4409c235642 8008537: Missing method reference lookup error when unbound search finds a static method
mcimadamore
parents: 16294
diff changeset
    49
16294
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    50
    void testBound() {
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    51
        String s1 = g(this::m0); //ok - resolves to g(Sam0)
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    52
        String s2 = g(this::m1); //ok - resolves to g(Sam1)
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    53
        String s3 = g(this::m2); //ok - resolves to g(Sam2)
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    54
        String s4 = g(this::m01);//ambiguous (g(Sam0), g(Sam1) apply)
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    55
        String s5 = g(this::m012);//ambiguous (g(Sam0), g(Sam1), g(Sam2) apply)
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    56
    }
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    57
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    58
    static void testUnbound() {
16323
c4409c235642 8008537: Missing method reference lookup error when unbound search finds a static method
mcimadamore
parents: 16294
diff changeset
    59
        TargetType60 s1 = u(TargetType60::n0); //ok - resolves to u(Sam1)
21718
74a5882faf79 8026231: Look at 'static' flag when checking method references
vromero
parents: 16323
diff changeset
    60
        TargetType60 s2 = u(TargetType60::n1); //ok - resolves to u(Sam2)
16323
c4409c235642 8008537: Missing method reference lookup error when unbound search finds a static method
mcimadamore
parents: 16294
diff changeset
    61
        TargetType60 s3 = u(TargetType60::n2); //none is applicable
c4409c235642 8008537: Missing method reference lookup error when unbound search finds a static method
mcimadamore
parents: 16294
diff changeset
    62
        TargetType60 s4 = u(TargetType60::n01);//ambiguous (u(Sam1), u(Sam2) apply)
c4409c235642 8008537: Missing method reference lookup error when unbound search finds a static method
mcimadamore
parents: 16294
diff changeset
    63
        TargetType60 s5 = u(TargetType60::n012);//ambiguous (u(Sam1), u(Sam2) apply)
16294
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    64
    }
0c291a3cd60d 8007462: Fix provisional applicability for method references
mcimadamore
parents:
diff changeset
    65
}