Skip to content

Commit

Permalink
GROOVY-9771
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Oct 7, 2020
1 parent 632e2bd commit 116dc80
Show file tree
Hide file tree
Showing 4 changed files with 440 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5142,4 +5142,28 @@ public void testCompileStatic9762() {

runConformTest(sources, "[123]");
}

@Test
public void testCompileStatic9771() {
//@formatter:off
String[] sources = {
"Main.groovy",
"@groovy.transform.CompileStatic\n" +
"class Main {\n" +
" private final Map<String, Boolean> map = [:]\n" +
" void test() {\n" +
" { ->\n" +
" map['key'] = true\n" +
" }.call()\n" +
" print map\n" +
" }\n" +
" static main(args) {\n" +
" newInstance().test()\n" +
" }\n" +
"}\n",
};
//@formatter:on

runConformTest(sources, "[key:true]");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.codehaus.groovy.syntax.Token;
import org.codehaus.groovy.syntax.TokenUtil;
import org.codehaus.groovy.transform.sc.StaticCompilationMetadataKeys;
import org.codehaus.groovy.transform.sc.StaticCompilationVisitor;
import org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor;
import org.codehaus.groovy.transform.stc.StaticTypesMarker;
import groovyjarjarasm.asm.Label;
Expand Down Expand Up @@ -405,9 +406,7 @@ protected void assignToArray(Expression parent, Expression receiver, Expression
*******/

WriterController controller = getController();
/* GRECLIPSE edit -- GROOVY-9699
StaticTypeCheckingVisitor visitor = new StaticCompilationVisitor(controller.getSourceUnit(), controller.getClassNode());
*/
// let's replace this assignment to a subscript operator with a
// method call
// e.g. x[5] = 10
Expand All @@ -425,9 +424,11 @@ protected void assignToArray(Expression parent, Expression receiver, Expression
ae
);
mce.setSourcePosition(parent);
/* GRECLIPSE edit -- GROOVY-9699
/* GRECLIPSE edit -- GROOVY-9699, GROOVY-9771
visitor.visitMethodCallExpression(mce);
*/
receiver.visit(visitor);
// GRECLIPSE end
OperandStack operandStack = controller.getOperandStack();
int height = operandStack.getStackLength();
mce.visit(controller.getAcg());
Expand Down
1 change: 1 addition & 0 deletions base/org.codehaus.groovy30/.checkstyle
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<file-match-pattern match-pattern="groovy/classgen/Verifier.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/StaticTypesBinaryExpressionMultiTypeDispatcher.java" include-pattern="false" />
<file-match-pattern match-pattern="groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.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" />
Expand Down
Loading

0 comments on commit 116dc80

Please sign in to comment.