Skip to content

Commit 984dc4f

Browse files
committed
GROOVY-10933
1 parent dbbea93 commit 984dc4f

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

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

+24
Original file line numberDiff line numberDiff line change
@@ -8100,4 +8100,28 @@ public void testCompileStatic10904() {
81008100

81018101
runConformTest(sources, "1");
81028102
}
8103+
8104+
@Test
8105+
public void testCompileStatic10933() {
8106+
assumeTrue(isParrotParser());
8107+
8108+
//@formatter:off
8109+
String[] sources = {
8110+
"Main.groovy",
8111+
"@groovy.transform.CompileStatic\n" +
8112+
"class Main {\n" +
8113+
" List<String> strings = []\n" +
8114+
" void run() {\n" +
8115+
" Optional.of('works').ifPresent(strings::add)\n" +
8116+
" }\n" +
8117+
" static main(args) {\n" +
8118+
" def obj = this.newInstance()\n" +
8119+
" obj.run(); print obj.strings\n" +
8120+
" }\n" +
8121+
"}\n",
8122+
};
8123+
//@formatter:on
8124+
8125+
runConformTest(sources, "[works]");
8126+
}
81038127
}

base/org.codehaus.groovy30/src/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java

+4
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ public void writeMethodReferenceExpression(final MethodReferenceExpression metho
147147
parametersWithExactType,
148148
false
149149
);
150+
// GRECLIPSE add -- GROOVY-10933
151+
if (abstractMethod.isVoidMethod()) bootstrapArgs[2] = groovyjarjarasm.asm.Type.getType(
152+
BytecodeHelper.getMethodDescriptor(ClassHelper.VOID_TYPE, parametersWithExactType));
153+
// GRECLIPSE end
150154
controller.getMethodVisitor().visitInvokeDynamicInsn(methodName, methodDesc, bootstrapMethod, bootstrapArgs);
151155

152156
if (isClassExpression) {

base/org.codehaus.groovy40/src/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java

+4
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ public void writeMethodReferenceExpression(final MethodReferenceExpression metho
174174
parametersWithExactType,
175175
false
176176
);
177+
// GRECLIPSE add -- GROOVY-10933
178+
if (abstractMethod.isVoidMethod()) bootstrapArgs[2] = groovyjarjarasm.asm.Type.getType(
179+
BytecodeHelper.getMethodDescriptor(ClassHelper.VOID_TYPE, parametersWithExactType));
180+
// GRECLIPSE end
177181
controller.getMethodVisitor().visitInvokeDynamicInsn(methodName, methodDesc, bootstrapMethod, bootstrapArgs);
178182

179183
if (isClassExpression) {

0 commit comments

Comments
 (0)