@@ -4676,15 +4676,11 @@ public void testCompileStatic9089() {
46764676 " print 'inner delegate'\n " +
46774677 " }\n " +
46784678 "}\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 " +
46834681 "}\n " +
4684- "@SuppressWarnings('rawtypes')\n " +
46854682 "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 " +
46884684 "}\n " +
46894685 "@groovy.transform.CompileStatic\n " +
46904686 "void test() {\n " +
@@ -4703,6 +4699,42 @@ public void testCompileStatic9089() {
47034699
47044700 @ Test
47054701 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 () {
47064738 //@formatter:off
47074739 String [] sources = {
47084740 "Main.groovy" ,
@@ -4716,15 +4748,13 @@ public void testCompileStatic9089a() {
47164748 " print 'inner delegate'\n " +
47174749 " }\n " +
47184750 "}\n " +
4719- "@SuppressWarnings('rawtypes')\n " +
47204751 "void outer(@DelegatesTo(value = C1) Closure block) {\n " +
47214752 " block.delegate = new C1()\n " +
4722- " block()\n " +
4753+ " block.call ()\n " +
47234754 "}\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 " +
47264756 " block.delegate = new C2()\n " +
4727- " block()\n " +
4757+ " block.call ()\n " +
47284758 "}\n " +
47294759 "@groovy.transform.CompileStatic\n " +
47304760 "void test() {\n " +
0 commit comments