From 306c4962687b014075fdb661b97e5f8bb67ab4b3 Mon Sep 17 00:00:00 2001 From: Eric Milles Date: Wed, 9 Aug 2023 14:10:43 -0500 Subject: [PATCH] GROOVY-11010 alternatives --- .../tests/xform/StaticCompilationTests.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) 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 9fa5877954..5986f31d67 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 @@ -8203,6 +8203,31 @@ public void testCompileStatic10972() { runConformTest(sources, "works"); } + @Test + public void testCompileStatic11010() { + assumeTrue(isParrotParser()); + + for (String xform : new String[] {"(String s) -> s.toInteger()", "{String s -> s.toInteger()}", + "(Function) String::toInteger"/*, "String::toInteger", "this::m", "this.&m"*/}) { + //@formatter:off + String[] sources = { + "Main.groovy", + "import java.util.function.*\n" + + " V from(Function f) { f.apply('42') }\n" + + " V from(Supplier s) { s.get() }\n" + + "int m(String str) { str.toInteger() }\n" + + "@groovy.transform.CompileStatic\n" + + "void test() {\n" + + " print(from(" + xform + "))\n" + + "}\n" + + "test()\n", + }; + //@formatter:on + + runConformTest(sources, "42"); + } + } + @Test public void testCompileStatic11029() { //@formatter:off