Sat, 22 Dec 2018 13:10:38 -0800
Added tag jdk8u202-b25 for changeset 15d8c732039b
1 /*
2 * @test /nodynamiccopyright/
3 * @bug 8003280 8029718
4 * @summary Add lambda tests
5 * check overload resolution and target type inference w.r.t. generic methods
6 * Should always use lambda body structure to disambiguate overload resolution
7 * @author Maurizio Cimadamore
8 * @compile/fail/ref=TargetType02.out -XDrawDiagnostics TargetType02.java
9 */
11 public class TargetType02 {
13 interface S1<X extends Number> {
14 X m(Integer x);
15 }
17 interface S2<X extends String> {
18 abstract X m(Integer x);
19 }
21 static <Z extends Number> void call1(S1<Z> s) { }
23 static <Z extends String> void call2(S2<Z> s) { }
25 static <Z extends Number> void call3(S1<Z> s) { }
26 static <Z extends String> void call3(S2<Z> s) { }
28 static <Z extends Number> Z call4(S1<Z> s) { return null; }
29 static <Z extends String> Z call4(S2<Z> s) { return null; }
31 void test() {
32 call1(i -> { toString(); return i; });
33 call2(i -> { toString(); return i; });
34 call3(i -> { toString(); return i; });
35 call3(i -> {
36 toString();
37 return call4(j -> {
38 return j;
39 });
40 });
41 }
42 }