diff --git a/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/StaticCompilationTests.java b/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/StaticCompilationTests.java index 04ab2360e8..a552704c99 100644 --- a/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/StaticCompilationTests.java +++ b/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/StaticCompilationTests.java @@ -6108,7 +6108,7 @@ public void testCompileStatic10033() { "Main.groovy", "@groovy.transform.CompileStatic\n" + "class Main {\n" + - " Main(java.util.function.Function f) {" + + " Main(java.util.function.Function f) {\n" + " print f.apply(this)\n" + " }\n" + " String m() { 'works' }\n" + @@ -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
f) {\n" + + " f.get()\n" + + " }\n" + + "}\n", + }; + //@formatter:on + + runConformTest(sources, "works"); + } + @Test public void testCompileStatic10047() { assumeTrue(isParrotParser()); diff --git a/base/org.codehaus.groovy30/src/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java b/base/org.codehaus.groovy30/src/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java index 1b2a9d8287..98fbefc39a 100644 --- a/base/org.codehaus.groovy30/src/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java +++ b/base/org.codehaus.groovy30/src/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java @@ -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; @@ -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; @@ -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); @@ -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; } @@ -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; } diff --git a/base/org.codehaus.groovy40/src/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java b/base/org.codehaus.groovy40/src/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java index 1b2a9d8287..98fbefc39a 100644 --- a/base/org.codehaus.groovy40/src/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java +++ b/base/org.codehaus.groovy40/src/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java @@ -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; @@ -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; @@ -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); @@ -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; } @@ -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; }