Skip to content

Commit

Permalink
GROOVY-9089
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Oct 23, 2022
1 parent b7f9539 commit 922e5a9
Show file tree
Hide file tree
Showing 7 changed files with 874 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4676,15 +4676,11 @@ public void testCompileStatic9089() {
" print 'inner delegate'\n" +
" }\n" +
"}\n" +
"@SuppressWarnings('rawtypes')\n" +
"void outer(@DelegatesTo(value = C1) Closure block) {\n" +
" block.delegate = new C1()\n" +
" block()\n" +
"void outer(@DelegatesTo(value = C1, strategy = Closure.DELEGATE_FIRST) Closure block) {\n" +
" new C1().with(block)\n" +
"}\n" +
"@SuppressWarnings('rawtypes')\n" +
"void inner(@DelegatesTo(value = C2, strategy = Closure.DELEGATE_FIRST) Closure block) {\n" +
" block.delegate = new C2()\n" +
" block()\n" +
" new C2().with(block)\n" +
"}\n" +
"@groovy.transform.CompileStatic\n" +
"void test() {\n" +
Expand All @@ -4703,6 +4699,42 @@ public void testCompileStatic9089() {

@Test
public void testCompileStatic9089a() {
//@formatter:off
String[] sources = {
"Main.groovy",
"class C1 {\n" +
" String getP() {\n" +
" 'outer delegate'\n" +
" }\n" +
"}\n" +
"class C2 {\n" +
" String getP() {\n" +
" 'inner delegate'\n" +
" }\n" +
"}\n" +
"void outer(@DelegatesTo(value = C1, strategy = Closure.DELEGATE_FIRST) Closure block) {\n" +
" new C1().with(block)\n" +
"}\n" +
"void inner(@DelegatesTo(value = C2, strategy = Closure.DELEGATE_FIRST) Closure block) {\n" +
" new C2().with(block)\n" +
"}\n" +
"@groovy.transform.CompileStatic\n" +
"void test() {\n" +
" outer {\n" +
" inner {\n" +
" this.print(owner.p)\n" +
" }\n" +
" }\n" +
"}\n" +
"test()\n",
};
//@formatter:on

runConformTest(sources, "outer delegate");
}

@Test
public void testCompileStatic9089b() {
//@formatter:off
String[] sources = {
"Main.groovy",
Expand All @@ -4716,15 +4748,13 @@ public void testCompileStatic9089a() {
" print 'inner delegate'\n" +
" }\n" +
"}\n" +
"@SuppressWarnings('rawtypes')\n" +
"void outer(@DelegatesTo(value = C1) Closure block) {\n" +
" block.delegate = new C1()\n" +
" block()\n" +
" block.call()\n" +
"}\n" +
"@SuppressWarnings('rawtypes')\n" +
"void inner(@DelegatesTo(value = C2, strategy = Closure.OWNER_FIRST) Closure block) {\n" +
"void inner(@DelegatesTo(value = C2) Closure block) {\n" +
" block.delegate = new C2()\n" +
" block()\n" +
" block.call()\n" +
"}\n" +
"@groovy.transform.CompileStatic\n" +
"void test() {\n" +
Expand Down
1 change: 1 addition & 0 deletions base/org.codehaus.groovy25/.checkstyle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<file-match-pattern match-pattern="groovy/classgen/asm/CompileStack.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/classgen/asm/InvocationWriter.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/classgen/asm/(Optimizing)?StatementWriter.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/classgen/asm/sc/StaticInvocationWriter.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/classgen/asm/sc/StaticPropertyAccessHelper.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/classgen/asm/sc/StaticTypes(CallSite|Statement)Writer.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/classgen/asm/sc/StaticTypesBinaryExpressionMultiTypeDispatcher.java" include-pattern="false" />
Expand Down
Loading

0 comments on commit 922e5a9

Please sign in to comment.