Skip to content

Commit

Permalink
GROOVY-10033 (pt.3)
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Apr 22, 2021
1 parent 47fc4ae commit b8b8cbe
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6108,7 +6108,7 @@ public void testCompileStatic10033() {
"Main.groovy",
"@groovy.transform.CompileStatic\n" +
"class Main {\n" +
" Main(java.util.function.Function<Main,String> f) {" +
" Main(java.util.function.Function<Main,String> f) {\n" +
" print f.apply(this)\n" +
" }\n" +
" String m() { 'works' }\n" +
Expand All @@ -6122,6 +6122,31 @@ public void testCompileStatic10033() {
runConformTest(sources, "works");
}

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

//@formatter:off
String[] sources = {
"Main.groovy",
"@groovy.transform.CompileStatic\n" +
"class Main {\n" +
" Main() {\n" +
" print 'works'\n" +
" }\n" +
" static main(args) {\n" +
" test(Main::new)\n" +
" }\n" +
" static test(java.util.function.Supplier<Main> f) {\n" +
" f.get()\n" +
" }\n" +
"}\n",
};
//@formatter:on

runConformTest(sources, "works");
}

@Test
public void testCompileStatic10047() {
assumeTrue(isParrotParser());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import groovy.lang.Tuple;
import groovy.lang.Tuple2;
import groovy.transform.CompileStatic;
import groovy.transform.Generated;
import org.codehaus.groovy.ast.ASTNode;
import org.codehaus.groovy.ast.AnnotationNode;
Expand All @@ -40,6 +39,7 @@
import org.codehaus.groovy.classgen.asm.WriterController;
import org.codehaus.groovy.runtime.ArrayTypeUtils;
import org.codehaus.groovy.syntax.RuntimeParserException;
import org.codehaus.groovy.transform.sc.StaticCompilationMetadataKeys;
import org.codehaus.groovy.transform.stc.ExtensionMethodNode;
import groovyjarjarasm.asm.Opcodes;

Expand Down Expand Up @@ -68,7 +68,9 @@
public class StaticTypesMethodReferenceExpressionWriter extends MethodReferenceExpressionWriter implements AbstractFunctionalInterfaceWriter {
private static final String METHODREF_EXPR_INSTANCE = "__METHODREF_EXPR_INSTANCE";
private static final ClassNode GENERATED_TYPE = ClassHelper.make(Generated.class);
/* GRECLIPSE edit -- GROOVY-10033
private static final ClassNode COMPILE_STATIC_TYPE = ClassHelper.make(CompileStatic.class);
*/

public StaticTypesMethodReferenceExpressionWriter(final WriterController controller) {
super(controller);
Expand Down Expand Up @@ -194,7 +196,9 @@ private MethodNode addSyntheticMethodForDGSM(final MethodNode mn) {
);

syntheticMethodNode.addAnnotation(new AnnotationNode(GENERATED_TYPE));
/* GRECLIPSE edit -- GROOVY-10033
syntheticMethodNode.addAnnotation(new AnnotationNode(COMPILE_STATIC_TYPE));
*/

return syntheticMethodNode;
}
Expand Down Expand Up @@ -224,7 +228,11 @@ private MethodNode addSyntheticMethodForConstructorReference(final String synthe
);

syntheticMethodNode.addAnnotation(new AnnotationNode(GENERATED_TYPE));
/* GRECLIPSE edit -- GROOVY-10033
syntheticMethodNode.addAnnotation(new AnnotationNode(COMPILE_STATIC_TYPE));
*/
syntheticMethodNode.putNodeMetaData(StaticCompilationMetadataKeys.STATIC_COMPILE_NODE, Boolean.FALSE);
// GRECLIPSE end

return syntheticMethodNode;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import groovy.lang.Tuple;
import groovy.lang.Tuple2;
import groovy.transform.CompileStatic;
import groovy.transform.Generated;
import org.codehaus.groovy.ast.ASTNode;
import org.codehaus.groovy.ast.AnnotationNode;
Expand All @@ -40,6 +39,7 @@
import org.codehaus.groovy.classgen.asm.WriterController;
import org.codehaus.groovy.runtime.ArrayTypeUtils;
import org.codehaus.groovy.syntax.RuntimeParserException;
import org.codehaus.groovy.transform.sc.StaticCompilationMetadataKeys;
import org.codehaus.groovy.transform.stc.ExtensionMethodNode;
import groovyjarjarasm.asm.Opcodes;

Expand Down Expand Up @@ -68,7 +68,9 @@
public class StaticTypesMethodReferenceExpressionWriter extends MethodReferenceExpressionWriter implements AbstractFunctionalInterfaceWriter {
private static final String METHODREF_EXPR_INSTANCE = "__METHODREF_EXPR_INSTANCE";
private static final ClassNode GENERATED_TYPE = ClassHelper.make(Generated.class);
/* GRECLIPSE edit -- GROOVY-10033
private static final ClassNode COMPILE_STATIC_TYPE = ClassHelper.make(CompileStatic.class);
*/

public StaticTypesMethodReferenceExpressionWriter(final WriterController controller) {
super(controller);
Expand Down Expand Up @@ -194,7 +196,9 @@ private MethodNode addSyntheticMethodForDGSM(final MethodNode mn) {
);

syntheticMethodNode.addAnnotation(new AnnotationNode(GENERATED_TYPE));
/* GRECLIPSE edit -- GROOVY-10033
syntheticMethodNode.addAnnotation(new AnnotationNode(COMPILE_STATIC_TYPE));
*/

return syntheticMethodNode;
}
Expand Down Expand Up @@ -224,7 +228,11 @@ private MethodNode addSyntheticMethodForConstructorReference(final String synthe
);

syntheticMethodNode.addAnnotation(new AnnotationNode(GENERATED_TYPE));
/* GRECLIPSE edit -- GROOVY-10033
syntheticMethodNode.addAnnotation(new AnnotationNode(COMPILE_STATIC_TYPE));
*/
syntheticMethodNode.putNodeMetaData(StaticCompilationMetadataKeys.STATIC_COMPILE_NODE, Boolean.FALSE);
// GRECLIPSE end

return syntheticMethodNode;
}
Expand Down

0 comments on commit b8b8cbe

Please sign in to comment.