1 /*
 2  * @test /nodynamiccopyright/
 3  * @bug 8205910
 4  * @summary Complain when `this' of a value class is leaked from constructor before all instance fields are definitely assigned.
 5  * @compile/fail/ref=MiscThisLeak.out -XDrawDiagnostics -XDdev -XDenablePrimitiveClasses MiscThisLeak.java
 6  */
 7 
 8 public class MiscThisLeak {
 9     interface I {
10         void foo();
11     }
12     primitive class V {
13         class K {}
14         int f;
15         V() {
16             I i = this::foo; // !OK.
17             i = MiscThisLeak.this::foo; // OK.
18             new K(); // !OK.
19             this.new K(); // !OK.
20             f = 10;
21             i = this::foo;   // OK.
22         }
23         void foo() {
24         }
25     }
26     void foo() {
27     }
28 }