File: TargetType22.java

package info (click to toggle)
libnb-javaparser-java 9%2B2018-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 65,172 kB
  • sloc: java: 440,096; xml: 6,359; sh: 865; makefile: 314
file content (44 lines) | stat: -rw-r--r-- 960 bytes parent folder | download | duplicates (19)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
 * @test /nodynamiccopyright/
 * @bug 8003280
 * @summary Add lambda tests
 *  check that candidates with incompatible SAM descriptor args length
            are removed from the set of applicable methods
 * @compile/fail/ref=TargetType22.out -Xlint:unchecked -XDrawDiagnostics TargetType22.java
 */

class TargetType22 {

    interface Sam0 {
        void m();
    }

    interface Sam1<A> {
        void m(A a);
    }

    interface Sam2<A> {
        void m(A a1, A a2);
    }

    interface Sam3<A> {
        void m(A a1, A a2, A a3);
    }

    interface SamX<A> {
        void m(A... as);
    }

    void call(Sam0 s) { }
    void call(Sam1<String> s) { }
    void call(Sam2<String> s) { }
    void call(Sam3<String> s) { }
    void call(SamX<String> s) { }

    void test() {
        call(() -> { });
        call(a1 -> { }); //ambiguous - both call(Sam1) and call(SamX) match
        call((a1, a2) -> { });
        call((a1, a2, a3) -> { });
    }
}