langtools/test/tools/javac/lambda/MethodReference48.java
author mcimadamore
Wed, 26 Oct 2016 15:41:25 +0100
changeset 41856 13a056e8f16e
parent 19929 39df7cd8039a
permissions -rw-r--r--
8168774: Polymorhic signature method check crashes javac Summary: Check for polysig method assumes arity is greater than zero Reviewed-by: vromero
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14547
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
     1
/*
19929
39df7cd8039a 8024154: Fix for 8016177: structural most specific and stuckness breaks 6 langtools tests
vromero
parents: 19914
diff changeset
     2
 * @test /nodynamiccopyright/
14547
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 raw qualifier in unbound method reference is inferred from descriptor
19914
d86271bd430a 8016177: structural most specific and stuckness
vromero
parents: 14547
diff changeset
     6
 * @compile/fail/ref=MethodReference48.out -XDrawDiagnostics MethodReference48.java
14547
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
     7
 */
19929
39df7cd8039a 8024154: Fix for 8016177: structural most specific and stuckness breaks 6 langtools tests
vromero
parents: 19914
diff changeset
     8
14547
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
     9
public class MethodReference48 {
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    10
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    11
    static class Foo<X> {
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    12
        X m() { return null; };
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    13
    }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    14
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    15
    interface SAM1 {
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    16
        Foo<Object> m(Foo<String> fs);
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    17
    }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    18
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    19
    interface SAM2 {
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    20
        Integer m(Foo<Integer> fi);
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    21
    }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    22
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    23
    interface SAM3 {
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    24
        Object m(Foo<Integer> fi);
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    25
    }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    26
19914
d86271bd430a 8016177: structural most specific and stuckness
vromero
parents: 14547
diff changeset
    27
    static void g1(SAM1 s) { } //return type not compatible
d86271bd430a 8016177: structural most specific and stuckness
vromero
parents: 14547
diff changeset
    28
d86271bd430a 8016177: structural most specific and stuckness
vromero
parents: 14547
diff changeset
    29
    static void g2(SAM2 s) { } //ok
d86271bd430a 8016177: structural most specific and stuckness
vromero
parents: 14547
diff changeset
    30
d86271bd430a 8016177: structural most specific and stuckness
vromero
parents: 14547
diff changeset
    31
    static void g3(SAM3 s) { } //ok
d86271bd430a 8016177: structural most specific and stuckness
vromero
parents: 14547
diff changeset
    32
d86271bd430a 8016177: structural most specific and stuckness
vromero
parents: 14547
diff changeset
    33
    static void g4(SAM1 s) { } //return type not compatible
d86271bd430a 8016177: structural most specific and stuckness
vromero
parents: 14547
diff changeset
    34
    static void g4(SAM2 s) { } //ok
d86271bd430a 8016177: structural most specific and stuckness
vromero
parents: 14547
diff changeset
    35
    static void g4(SAM3 s) { } //ok
14547
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    36
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    37
    public static void main(String[] args) {
19914
d86271bd430a 8016177: structural most specific and stuckness
vromero
parents: 14547
diff changeset
    38
        g1(Foo::m);
d86271bd430a 8016177: structural most specific and stuckness
vromero
parents: 14547
diff changeset
    39
        g2(Foo::m);
d86271bd430a 8016177: structural most specific and stuckness
vromero
parents: 14547
diff changeset
    40
        g3(Foo::m);
d86271bd430a 8016177: structural most specific and stuckness
vromero
parents: 14547
diff changeset
    41
        g4(Foo::m);
14547
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    42
    }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    43
}