@@ -4676,15 +4676,11 @@ public void testCompileStatic9089() {
4676
4676
" print 'inner delegate'\n " +
4677
4677
" }\n " +
4678
4678
"}\n " +
4679
- "@SuppressWarnings('rawtypes')\n " +
4680
- "void outer(@DelegatesTo(value = C1) Closure block) {\n " +
4681
- " block.delegate = new C1()\n " +
4682
- " block()\n " +
4679
+ "void outer(@DelegatesTo(value = C1, strategy = Closure.DELEGATE_FIRST) Closure block) {\n " +
4680
+ " new C1().with(block)\n " +
4683
4681
"}\n " +
4684
- "@SuppressWarnings('rawtypes')\n " +
4685
4682
"void inner(@DelegatesTo(value = C2, strategy = Closure.DELEGATE_FIRST) Closure block) {\n " +
4686
- " block.delegate = new C2()\n " +
4687
- " block()\n " +
4683
+ " new C2().with(block)\n " +
4688
4684
"}\n " +
4689
4685
"@groovy.transform.CompileStatic\n " +
4690
4686
"void test() {\n " +
@@ -4703,6 +4699,42 @@ public void testCompileStatic9089() {
4703
4699
4704
4700
@ Test
4705
4701
public void testCompileStatic9089a () {
4702
+ //@formatter:off
4703
+ String [] sources = {
4704
+ "Main.groovy" ,
4705
+ "class C1 {\n " +
4706
+ " String getP() {\n " +
4707
+ " 'outer delegate'\n " +
4708
+ " }\n " +
4709
+ "}\n " +
4710
+ "class C2 {\n " +
4711
+ " String getP() {\n " +
4712
+ " 'inner delegate'\n " +
4713
+ " }\n " +
4714
+ "}\n " +
4715
+ "void outer(@DelegatesTo(value = C1, strategy = Closure.DELEGATE_FIRST) Closure block) {\n " +
4716
+ " new C1().with(block)\n " +
4717
+ "}\n " +
4718
+ "void inner(@DelegatesTo(value = C2, strategy = Closure.DELEGATE_FIRST) Closure block) {\n " +
4719
+ " new C2().with(block)\n " +
4720
+ "}\n " +
4721
+ "@groovy.transform.CompileStatic\n " +
4722
+ "void test() {\n " +
4723
+ " outer {\n " +
4724
+ " inner {\n " +
4725
+ " this.print(owner.p)\n " +
4726
+ " }\n " +
4727
+ " }\n " +
4728
+ "}\n " +
4729
+ "test()\n " ,
4730
+ };
4731
+ //@formatter:on
4732
+
4733
+ runConformTest (sources , "outer delegate" );
4734
+ }
4735
+
4736
+ @ Test
4737
+ public void testCompileStatic9089b () {
4706
4738
//@formatter:off
4707
4739
String [] sources = {
4708
4740
"Main.groovy" ,
@@ -4716,15 +4748,13 @@ public void testCompileStatic9089a() {
4716
4748
" print 'inner delegate'\n " +
4717
4749
" }\n " +
4718
4750
"}\n " +
4719
- "@SuppressWarnings('rawtypes')\n " +
4720
4751
"void outer(@DelegatesTo(value = C1) Closure block) {\n " +
4721
4752
" block.delegate = new C1()\n " +
4722
- " block()\n " +
4753
+ " block.call ()\n " +
4723
4754
"}\n " +
4724
- "@SuppressWarnings('rawtypes')\n " +
4725
- "void inner(@DelegatesTo(value = C2, strategy = Closure.OWNER_FIRST) Closure block) {\n " +
4755
+ "void inner(@DelegatesTo(value = C2) Closure block) {\n " +
4726
4756
" block.delegate = new C2()\n " +
4727
- " block()\n " +
4757
+ " block.call ()\n " +
4728
4758
"}\n " +
4729
4759
"@groovy.transform.CompileStatic\n " +
4730
4760
"void test() {\n " +
0 commit comments