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 c41b55b073..3f9431b6ab 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 @@ -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 implements Iterable {\n" + + " Iterator iterator() {\n" + + " list.iterator()\n" + + " }\n" + + " List 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]"); + } } diff --git a/base/org.codehaus.groovy25/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java b/base/org.codehaus.groovy25/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java index 7f72e2f6f6..c0ce8848db 100644 --- a/base/org.codehaus.groovy25/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java +++ b/base/org.codehaus.groovy25/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java @@ -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(); diff --git a/base/org.codehaus.groovy30/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java b/base/org.codehaus.groovy30/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java index 74fe22e69c..a5d5e4118c 100644 --- a/base/org.codehaus.groovy30/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java +++ b/base/org.codehaus.groovy30/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java @@ -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(); diff --git a/base/org.codehaus.groovy40/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java b/base/org.codehaus.groovy40/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java index f0b21a136f..ffe5b2c463 100644 --- a/base/org.codehaus.groovy40/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java +++ b/base/org.codehaus.groovy40/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java @@ -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();