Skip to content

Commit 922e5a9

Browse files
committed
GROOVY-9089
1 parent b7f9539 commit 922e5a9

File tree

7 files changed

+874
-58
lines changed

7 files changed

+874
-58
lines changed

base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/StaticCompilationTests.java

+42-12
Original file line numberDiff line numberDiff line change
@@ -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" +

base/org.codehaus.groovy25/.checkstyle

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
<file-match-pattern match-pattern="groovy/classgen/asm/CompileStack.java" include-pattern="false" />
4242
<file-match-pattern match-pattern="groovy/classgen/asm/InvocationWriter.java" include-pattern="false" />
4343
<file-match-pattern match-pattern="groovy/classgen/asm/(Optimizing)?StatementWriter.java" include-pattern="false" />
44+
<file-match-pattern match-pattern="groovy/classgen/asm/sc/StaticInvocationWriter.java" include-pattern="false" />
4445
<file-match-pattern match-pattern="groovy/classgen/asm/sc/StaticPropertyAccessHelper.java" include-pattern="false" />
4546
<file-match-pattern match-pattern="groovy/classgen/asm/sc/StaticTypes(CallSite|Statement)Writer.java" include-pattern="false" />
4647
<file-match-pattern match-pattern="groovy/classgen/asm/sc/StaticTypesBinaryExpressionMultiTypeDispatcher.java" include-pattern="false" />

0 commit comments

Comments
 (0)