Skip to content

Commit

Permalink
GROOVY-10933
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Feb 14, 2023
1 parent dbbea93 commit 984dc4f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
Expand Up @@ -8100,4 +8100,28 @@ public void testCompileStatic10904() {

runConformTest(sources, "1");
}

@Test
public void testCompileStatic10933() {
assumeTrue(isParrotParser());

//@formatter:off
String[] sources = {
"Main.groovy",
"@groovy.transform.CompileStatic\n" +
"class Main {\n" +
" List<String> strings = []\n" +
" void run() {\n" +
" Optional.of('works').ifPresent(strings::add)\n" +
" }\n" +
" static main(args) {\n" +
" def obj = this.newInstance()\n" +
" obj.run(); print obj.strings\n" +
" }\n" +
"}\n",
};
//@formatter:on

runConformTest(sources, "[works]");
}
}
Expand Up @@ -147,6 +147,10 @@ public void writeMethodReferenceExpression(final MethodReferenceExpression metho
parametersWithExactType,
false
);
// GRECLIPSE add -- GROOVY-10933
if (abstractMethod.isVoidMethod()) bootstrapArgs[2] = groovyjarjarasm.asm.Type.getType(
BytecodeHelper.getMethodDescriptor(ClassHelper.VOID_TYPE, parametersWithExactType));
// GRECLIPSE end
controller.getMethodVisitor().visitInvokeDynamicInsn(methodName, methodDesc, bootstrapMethod, bootstrapArgs);

if (isClassExpression) {
Expand Down
Expand Up @@ -174,6 +174,10 @@ public void writeMethodReferenceExpression(final MethodReferenceExpression metho
parametersWithExactType,
false
);
// GRECLIPSE add -- GROOVY-10933
if (abstractMethod.isVoidMethod()) bootstrapArgs[2] = groovyjarjarasm.asm.Type.getType(
BytecodeHelper.getMethodDescriptor(ClassHelper.VOID_TYPE, parametersWithExactType));
// GRECLIPSE end
controller.getMethodVisitor().visitInvokeDynamicInsn(methodName, methodDesc, bootstrapMethod, bootstrapArgs);

if (isClassExpression) {
Expand Down

0 comments on commit 984dc4f

Please sign in to comment.