Skip to content

Commit

Permalink
GROOVY-9968
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Mar 6, 2021
1 parent e6dfebc commit 26b4c8e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1090,4 +1090,29 @@ public void testTypeChecked9963() {

runConformTest(sources, "x");
}

@Test
public void testTypeChecked9968() {
//@formatter:off
String[] sources = {
"Main.groovy",
"import groovy.transform.*\n" +
"@Canonical class Pogo { String prop }\n" +
"@Canonical class IterableType<T extends Pogo> implements Iterable<T> {\n" +
" Iterator<T> iterator() {\n" +
" list.iterator()\n" +
" }\n" +
" List<T> list\n" +
"}\n" +
"@TypeChecked void test() {\n" +
" def iterable = new IterableType([new Pogo('x'), new Pogo('y'), new Pogo('z')])\n" +
" print iterable.collect { Pogo p -> p.prop }\n" +
" print iterable.collect { it.prop }\n" +
"}\n" +
"test()\n",
};
//@formatter:on

runConformTest(sources, "[x, y, z][x, y, z]");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3397,6 +3397,11 @@ private ClassNode[] resolveGenericsFromTypeHint(final ClassNode receiver, final
private static ClassNode createUsableClassNodeFromGenericsType(final GenericsType genericsType) {
ClassNode value = genericsType.getType();
if (genericsType.isPlaceholder()) {
// GRECLIPSE add -- GROOVY-9968
if (value.isRedirectNode())
value = value.redirect();
else
// GRECLIPSE end
value = OBJECT_TYPE;
}
ClassNode lowerBound = genericsType.getLowerBound();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3210,6 +3210,11 @@ private ClassNode[] resolveGenericsFromTypeHint(final ClassNode receiver, final
private static ClassNode createUsableClassNodeFromGenericsType(final GenericsType genericsType) {
ClassNode value = genericsType.getType();
if (genericsType.isPlaceholder()) {
// GRECLIPSE add -- GROOVY-9968
if (value.isRedirectNode())
value = value.redirect();
else
// GRECLIPSE end
value = OBJECT_TYPE;
}
ClassNode lowerBound = genericsType.getLowerBound();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3195,6 +3195,11 @@ private ClassNode[] resolveGenericsFromTypeHint(final ClassNode receiver, final
private static ClassNode createUsableClassNodeFromGenericsType(final GenericsType genericsType) {
ClassNode value = genericsType.getType();
if (genericsType.isPlaceholder()) {
// GRECLIPSE add -- GROOVY-9968
if (value.isRedirectNode())
value = value.redirect();
else
// GRECLIPSE end
value = OBJECT_TYPE;
}
ClassNode lowerBound = genericsType.getLowerBound();
Expand Down

0 comments on commit 26b4c8e

Please sign in to comment.