File: TargetType23.java

package info (click to toggle)
libnb-javaparser-java 9%2B2018-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 65,320 kB
  • sloc: java: 440,096; xml: 6,359; sh: 865; makefile: 314
file content (42 lines) | stat: -rw-r--r-- 856 bytes parent folder | download | duplicates (18)
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
/*
 * @test /nodynamiccopyright/
 * @bug 8003280 8034223
 * @summary Add lambda tests
 *  check case of ambiguous method call with lambda whose body cannot
            complete normally
 * @compile/fail/ref=TargetType23.out -XDrawDiagnostics TargetType23.java
 */

class TargetType23 {

    interface Sam0 {
        void m();
    }

    interface Sam1 {
        int m();
    }

    interface Sam2 {
        String m();
    }

    interface Sam3<A> {
        A m();
    }


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

    void call2(Sam0 s) { }
    void call2(Sam2 s) { }
    <Z> void call2(Sam3<Z> s) { }

    void test() {
        call(()-> { throw new RuntimeException(); }); // ambiguous - call(Sam1) vs. call(Sam2)
        call2(()-> { throw new RuntimeException(); }); // ok
    }
}