1 /*
 2  * @test /nodynamiccopyright/
 3  * @bug 8324873
 4  * @summary [lworld] implementation of value classes construction
 5  * @enablePreview
 6  * @compile/fail/ref=DA_DUConstructors.out -XDrawDiagnostics DA_DUConstructors.java
 7  */
 8 
 9 public class DA_DUConstructors {
10     // identity
11     class C1 {
12         final int x;
13         final int y = x + 1;
14         C1() {
15             x = 12;
16             super();
17         }
18     }
19 
20     class C2 {
21         final int x;
22         C2() {
23             this(x = 3); // error
24         }
25         C2(int i) {
26             x = 4;
27         }
28     }
29 
30     class C3 {
31         C3(int i) {}
32     }
33     class C4 extends C3 {
34         final int x;
35         C4() {
36             super(x = 3); // ok
37         }
38     }
39 
40     class C5 {
41         final int x;
42         final int y = x + 1; // x is not DA
43         C5() {
44             x = 12; super();
45         }
46         C5(int i) {
47             /* no prologue */
48             x = i;
49         }
50     }
51 
52     // value classes
53     value class V1 {
54         int x;
55         int y = x + 1; // allowed
56         V1() {
57             x = 12;
58             // super();
59         }
60     }
61 
62     value class V2 {
63         int x;
64         V2() { this(x = 3); } // error
65         V2(int i) { x = 4; }
66     }
67 
68     abstract value class AV1 {
69         AV1(int i) {}
70     }
71 
72     value class V3 extends AV1 {
73         int x;
74         V3() {
75             super(x = 3); // ok
76         }
77     }
78 
79     value class V4 { // OK
80         int x;
81         int y = x + 1;
82 
83         V4() {
84             x = 12;
85         }
86 
87         V4(int i) {
88             x = i;
89         }
90     }
91 }