Skip to content

Commit 0a77b5e

Browse files
committed
GROOVY-10330
1 parent bbf178a commit 0a77b5e

File tree

4 files changed

+36
-3
lines changed

4 files changed

+36
-3
lines changed

base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/TypeCheckedTests.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4294,4 +4294,29 @@ public void testTypeChecked10327() {
42944294

42954295
runConformTest(sources);
42964296
}
4297+
4298+
@Test
4299+
public void testTypeChecked10330() {
4300+
if (Float.parseFloat(System.getProperty("java.specification.version")) > 8)
4301+
vmArguments = new String[] {"--add-opens", "java.base/java.util.function=ALL-UNNAMED"};
4302+
4303+
//@formatter:off
4304+
String[] sources = {
4305+
"Main.groovy",
4306+
"@groovy.transform.TypeChecked\n" +
4307+
"class C<T> {\n" +
4308+
" T y\n" +
4309+
" void m(T x, java.util.function.Function<T, T> f) {\n" +
4310+
" print f.apply(x)\n" +
4311+
" }\n" +
4312+
" void test(T x, java.util.function.Function<T, T> f) {\n" +
4313+
" m(true ? x : y, f)\n" +
4314+
" }\n" +
4315+
"}\n" +
4316+
"new C<String>().test('WORKS', { it.toLowerCase() })\n",
4317+
};
4318+
//@formatter:on
4319+
4320+
runConformTest(sources, "works");
4321+
}
42974322
}

base/org.codehaus.groovy25/src/org/codehaus/groovy/ast/tools/WideningCategories.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ public static ClassNode lowestUpperBound(List<ClassNode> nodes) {
209209
public static ClassNode lowestUpperBound(ClassNode a, ClassNode b) {
210210
ClassNode lub = lowestUpperBound(a, b, null, null);
211211
if (lub==null || !lub.isUsingGenerics()) return lub;
212+
// GRECLIPSE add -- GROOVY-10130
213+
if (lub.isGenericsPlaceHolder()) return lub;
214+
// GRECLIPSE end
212215
// types may be parameterized. If so, we must ensure that generic type arguments
213216
// are made compatible
214217

base/org.codehaus.groovy30/src/org/codehaus/groovy/ast/tools/WideningCategories.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ public static ClassNode lowestUpperBound(List<ClassNode> nodes) {
207207
public static ClassNode lowestUpperBound(ClassNode a, ClassNode b) {
208208
ClassNode lub = lowestUpperBound(a, b, null, null);
209209
if (lub==null || !lub.isUsingGenerics()) return lub;
210+
// GRECLIPSE add -- GROOVY-10130
211+
if (lub.isGenericsPlaceHolder()) return lub;
212+
// GRECLIPSE end
210213
// types may be parameterized. If so, we must ensure that generic type arguments
211214
// are made compatible
212215

base/org.codehaus.groovy40/src/org/codehaus/groovy/ast/tools/WideningCategories.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,12 @@ public static ClassNode lowestUpperBound(final List<ClassNode> nodes) {
213213
*/
214214
public static ClassNode lowestUpperBound(final ClassNode a, final ClassNode b) {
215215
ClassNode lub = lowestUpperBound(a, b, null, null);
216-
if (lub==null || !lub.isUsingGenerics()) return lub;
217-
// types may be parameterized. If so, we must ensure that generic type arguments
216+
if (lub == null || !lub.isUsingGenerics()
217+
|| lub.isGenericsPlaceHolder()) { // GROOVY-10330
218+
return lub;
219+
}
220+
// types may be parameterized; if so, ensure that generic type arguments
218221
// are made compatible
219-
220222
if (lub instanceof LowestUpperBoundClassNode) {
221223
// no parent super class representing both types could be found
222224
// or both class nodes implement common interfaces which may have

0 commit comments

Comments
 (0)