langtools/test/tools/javac/lambda/MethodReference46.java
author mcimadamore
Wed, 26 Oct 2016 15:41:25 +0100
changeset 41856 13a056e8f16e
parent 30014 fc1f2b200c1f
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/
30014
fc1f2b200c1f 8078024: javac, several incorporation steps are silently failing when an error should be reported
vromero
parents: 19929
diff changeset
     3
 * @bug 8003280 8078024
14547
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
19914
d86271bd430a 8016177: structural most specific and stuckness
vromero
parents: 14547
diff changeset
     6
 * @compile/fail/ref=MethodReference46.out -XDrawDiagnostics MethodReference46.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 MethodReference46 {
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    10
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    11
    interface SAM1 {
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    12
       void m(String s);
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 SAM2 {
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    16
       void m(Integer s);
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 SAM3 {
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    20
       void m(Object o);
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
    static class Foo<X extends Number> {
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    24
        Foo(X x) { }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    25
    }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    26
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    27
    static <X extends Number> void m(X fx) { }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    28
19914
d86271bd430a 8016177: structural most specific and stuckness
vromero
parents: 14547
diff changeset
    29
    static void g1(SAM1 s) { }
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 g2(SAM2 s) { }
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 g3(SAM3 s) { }
d86271bd430a 8016177: structural most specific and stuckness
vromero
parents: 14547
diff changeset
    34
d86271bd430a 8016177: structural most specific and stuckness
vromero
parents: 14547
diff changeset
    35
    static void g4(SAM1 s) { }
d86271bd430a 8016177: structural most specific and stuckness
vromero
parents: 14547
diff changeset
    36
    static void g4(SAM2 s) { }
d86271bd430a 8016177: structural most specific and stuckness
vromero
parents: 14547
diff changeset
    37
    static void g4(SAM3 s) { }
14547
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    38
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    39
    public static void main(String[] args) {
19914
d86271bd430a 8016177: structural most specific and stuckness
vromero
parents: 14547
diff changeset
    40
        g1(MethodReference46::m);
d86271bd430a 8016177: structural most specific and stuckness
vromero
parents: 14547
diff changeset
    41
        g2(MethodReference46::m);
d86271bd430a 8016177: structural most specific and stuckness
vromero
parents: 14547
diff changeset
    42
        g3(MethodReference46::m);
d86271bd430a 8016177: structural most specific and stuckness
vromero
parents: 14547
diff changeset
    43
        g4(MethodReference46::m);
14547
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    44
    }
86d8d242b0c4 8003280: Add lambda tests
mcimadamore
parents:
diff changeset
    45
}