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 4cefd28009..b0f3251e8f 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 @@ -4294,4 +4294,29 @@ public void testTypeChecked10327() { runConformTest(sources); } + + @Test + public void testTypeChecked10330() { + if (Float.parseFloat(System.getProperty("java.specification.version")) > 8) + vmArguments = new String[] {"--add-opens", "java.base/java.util.function=ALL-UNNAMED"}; + + //@formatter:off + String[] sources = { + "Main.groovy", + "@groovy.transform.TypeChecked\n" + + "class C {\n" + + " T y\n" + + " void m(T x, java.util.function.Function f) {\n" + + " print f.apply(x)\n" + + " }\n" + + " void test(T x, java.util.function.Function f) {\n" + + " m(true ? x : y, f)\n" + + " }\n" + + "}\n" + + "new C().test('WORKS', { it.toLowerCase() })\n", + }; + //@formatter:on + + runConformTest(sources, "works"); + } } diff --git a/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/tools/WideningCategories.java b/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/tools/WideningCategories.java index 794d1de833..c39d5a1d07 100644 --- a/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/tools/WideningCategories.java +++ b/base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/tools/WideningCategories.java @@ -209,6 +209,9 @@ public static ClassNode lowestUpperBound(List nodes) { public static ClassNode lowestUpperBound(ClassNode a, ClassNode b) { ClassNode lub = lowestUpperBound(a, b, null, null); if (lub==null || !lub.isUsingGenerics()) return lub; + // GRECLIPSE add -- GROOVY-10130 + if (lub.isGenericsPlaceHolder()) return lub; + // GRECLIPSE end // types may be parameterized. If so, we must ensure that generic type arguments // are made compatible diff --git a/base/org.codehaus.groovy30/src/org/codehaus/groovy/ast/tools/WideningCategories.java b/base/org.codehaus.groovy30/src/org/codehaus/groovy/ast/tools/WideningCategories.java index e367d1eb4f..3655982db1 100644 --- a/base/org.codehaus.groovy30/src/org/codehaus/groovy/ast/tools/WideningCategories.java +++ b/base/org.codehaus.groovy30/src/org/codehaus/groovy/ast/tools/WideningCategories.java @@ -207,6 +207,9 @@ public static ClassNode lowestUpperBound(List nodes) { public static ClassNode lowestUpperBound(ClassNode a, ClassNode b) { ClassNode lub = lowestUpperBound(a, b, null, null); if (lub==null || !lub.isUsingGenerics()) return lub; + // GRECLIPSE add -- GROOVY-10130 + if (lub.isGenericsPlaceHolder()) return lub; + // GRECLIPSE end // types may be parameterized. If so, we must ensure that generic type arguments // are made compatible diff --git a/base/org.codehaus.groovy40/src/org/codehaus/groovy/ast/tools/WideningCategories.java b/base/org.codehaus.groovy40/src/org/codehaus/groovy/ast/tools/WideningCategories.java index 687af0af98..5e9d8d4b54 100644 --- a/base/org.codehaus.groovy40/src/org/codehaus/groovy/ast/tools/WideningCategories.java +++ b/base/org.codehaus.groovy40/src/org/codehaus/groovy/ast/tools/WideningCategories.java @@ -213,10 +213,12 @@ public static ClassNode lowestUpperBound(final List nodes) { */ public static ClassNode lowestUpperBound(final ClassNode a, final ClassNode b) { ClassNode lub = lowestUpperBound(a, b, null, null); - if (lub==null || !lub.isUsingGenerics()) return lub; - // types may be parameterized. If so, we must ensure that generic type arguments + if (lub == null || !lub.isUsingGenerics() + || lub.isGenericsPlaceHolder()) { // GROOVY-10330 + return lub; + } + // types may be parameterized; if so, ensure that generic type arguments // are made compatible - if (lub instanceof LowestUpperBoundClassNode) { // no parent super class representing both types could be found // or both class nodes implement common interfaces which may have