1/*
2 * @test /nodynamiccopyright/
3 * @bug 8003280 8075184 8081271
4 * @summary Add lambda tests
5 *  check that pair of bound/non-bound constructor references is flagged as ambiguous
6 * @author  Maurizio Cimadamore
7 * @compile/fail/ref=MethodReference23.out -XDrawDiagnostics MethodReference23.java
8 */
9
10class MethodReference23 {
11
12    class Inner1 {
13        Inner1(MethodReference23 outer) {};
14        Inner1() {};
15    }
16
17    static class Inner2 {
18        Inner2(MethodReference23 outer) {};
19        Inner2() {};
20    }
21
22    interface SAM11 {
23        Inner1 m(MethodReference23 rec);
24    }
25
26    interface SAM12 {
27        Inner1 m();
28    }
29
30    interface SAM21 {
31        Inner2 m(MethodReference23 rec);
32    }
33
34    interface SAM22 {
35        Inner2 m();
36    }
37
38    static void call11(SAM11 s) {   }
39
40    static void call12(SAM12 s) {   }
41
42    static void call21(SAM21 s) {   }
43
44    static void call22(SAM22 s) {   }
45
46    static void call3(SAM11 s) {   }
47    static void call3(SAM12 s) {   }
48    static void call3(SAM21 s) {   }
49    static void call3(SAM22 s) {   }
50
51    static void test11() {
52        SAM11 s = MethodReference23.Inner1::new; // fail.
53        call11(MethodReference23.Inner1::new); // fail.
54    }
55
56    static void test12() {
57        SAM12 s = MethodReference23.Inner1::new; //fail
58        call12(MethodReference23.Inner1::new); //fail
59    }
60
61    static void test21() {
62        SAM21 s = MethodReference23.Inner2::new; //ok
63        call21(MethodReference23.Inner2::new); //ok
64    }
65
66    static void test22() {
67        SAM22 s = MethodReference23.Inner2::new; //ok
68        call22(MethodReference23.Inner2::new); //ok
69    }
70
71    static void test3() {
72        call3(MethodReference23.Inner2::new); //ambiguous
73    }
74}
75