Skip to content

Commit

Permalink
GROOVY-9892
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Jan 15, 2021
1 parent ed49333 commit 3bf39d8
Show file tree
Hide file tree
Showing 6 changed files with 1,829 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5480,4 +5480,30 @@ public void testCompileStatic9883() {
"Cannot assign java.util.function.Supplier <java.util.UUID> to: java.util.function.Supplier <String>\n" +
"----------\n");
}

@Test
public void testCompileStatic9892() {
//@formatter:off
String[] sources = {
"Main.groovy",
"@groovy.transform.CompileStatic\n" +
"class C {\n" +
" int prefix\n" +
" int postfix\n" +
" def test() {\n" +
" { ->\n" +
" print \"X${++prefix}Y${postfix++}\"\n" +
" }.call()\n" +
" true\n" +
" }\n" +
"}\n" +
"def c = new C()\n" +
"assert c.test()\n" +
"assert c.prefix == 1\n" +
"assert c.postfix == 1\n",
};
//@formatter:on

runConformTest(sources, "X1Y0");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ private void writeNumberNumberCall(final Expression receiver, final String messa

@Override
public void fallbackAttributeOrPropertySite(PropertyExpression expression, Expression objectExpression, String name, MethodCallerMultiAdapter adapter) {
/* GRECLIPSE edit -- GROOVY-7304
/* GRECLIPSE edit -- GROOVY-7304, GROOVY-9892
if (name!=null &&
(adapter == AsmClassGenerator.setField || adapter == AsmClassGenerator.setGroovyObjectField)
) {
Expand Down Expand Up @@ -913,6 +913,7 @@ public void fallbackAttributeOrPropertySite(PropertyExpression expression, Expre
call.visit(controller.getAcg());

controller.getCompileStack().removeVar(i);
controller.getOperandStack().pop();
return;
}
}
Expand Down
2 changes: 1 addition & 1 deletion base/org.codehaus.groovy30/.checkstyle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<file-match-pattern match-pattern="groovy/classgen/asm/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/StaticTypesMethodReferenceExpressionWriter.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/classgen/asm/sc/StaticTypes(CallSite|MethodReferenceExpression)Writer.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/control/CompilationUnit.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/control/CompilerConfiguration.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/control/ErrorCollector.java" include-pattern="false" />
Expand Down
Loading

0 comments on commit 3bf39d8

Please sign in to comment.