From 8328da8a6f0fe83b2b009c1d9e44d74ba175a99c Mon Sep 17 00:00:00 2001 From: Eric Milles Date: Tue, 28 Sep 2021 14:09:51 -0500 Subject: [PATCH] GROOVY-10234 --- .../core/tests/xform/TypeCheckedTests.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/TypeCheckedTests.java b/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/TypeCheckedTests.java index 380335fff2..3fb64e0d7d 100644 --- a/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/TypeCheckedTests.java +++ b/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/TypeCheckedTests.java @@ -3575,6 +3575,34 @@ public void testTypeChecked10225() { runConformTest(sources, "null"); } + @Test + public void testTypeChecked10234() { + //@formatter:off + String[] sources = { + "Main.groovy", + "def T getBean(Class beanType) {\n" + + " { obj, Class target -> Optional.of(obj.toString()) } as Service\n" + + "}\n" + + "@groovy.transform.TypeChecked\n" + + "void test() {\n" + + " print getBean(Service).convert(new ArrayList(), String).get()\n" + + "}\n" + + "test()\n", + + "Service.java", + "import java.util.Optional;\n" + + "import java.util.function.*;\n" + + "@SuppressWarnings(\"rawtypes\")" + + "public interface Service {\n" + + " Optional convert(Object object, Class targetType);\n" + + " Impl addConverter(Class sourceType, Class targetType, Function typeConverter);\n" + + "}\n", + }; + //@formatter:on + + runConformTest(sources, "[]"); + } + @Test public void testTypeChecked10235() { if (Float.parseFloat(System.getProperty("java.specification.version")) > 8)