diff --git a/base-test/org.eclipse.jdt.groovy.core.tests.builder/src/org/eclipse/jdt/core/groovy/tests/search/DGMInferencingTests.java b/base-test/org.eclipse.jdt.groovy.core.tests.builder/src/org/eclipse/jdt/core/groovy/tests/search/DGMInferencingTests.java index a745446a66..8769779aae 100644 --- a/base-test/org.eclipse.jdt.groovy.core.tests.builder/src/org/eclipse/jdt/core/groovy/tests/search/DGMInferencingTests.java +++ b/base-test/org.eclipse.jdt.groovy.core.tests.builder/src/org/eclipse/jdt/core/groovy/tests/search/DGMInferencingTests.java @@ -171,6 +171,29 @@ public void testDGM11() { assertExprType(contents, "index", "java.lang.Integer"); } + @Test + public void testDGM11a() { + //@formatter:off + String contents = + "def map = ['x'].collectEntries { [it, it.size()] }\n"; + //@formatter:on + assertExprType(contents, "it", "java.lang.String"); + assertExprType(contents, "map", "java.util.Map"); + } + + @Test // https://issues.apache.org/jira/browse/GROOVY-10036 + public void testDGM11b() { + //@formatter:off + String contents = + "@groovy.transform.TypeChecked\n" + + "void test() {\n" + + " def map = ['x'].collectEntries { [it, it.size()] }\n" + + "}\n"; + //@formatter:on + assertExprType(contents, "it", "java.lang.String"); + assertExprType(contents, "map", "java.util.Map"); + } + @Test public void testDGM12() { //@formatter:off @@ -469,8 +492,7 @@ public void testDGM42() { assertExprType(contents, "it", "java.lang.String"); } - @Test @Ignore("ClosureParams states 'List' or 'String[]', but " + - "runtime allows for destructuring if number of elements fits into params") + @Test @Ignore("ClosureParams states 'List' or 'String[]', but runtime allows for destructuring if number of elements fits into params") public void testDGM43() { //@formatter:off String contents = 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 27ddb9387f..194b9be4ca 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 @@ -5794,7 +5794,7 @@ protected ClassNode inferReturnTypeGenerics( } else { argList.addExpression(arguments); } - return inferReturnTypeGenerics(receiver, dgmMethod, argList); + return inferReturnTypeGenerics(receiver, dgmMethod, argList, explicitTypeHints); // GRECLIPSE edit -- GROOVY-10036 } if (!isUsingGenericsOrIsArrayUsingGenerics(returnType)) return returnType; if (getGenericsWithoutArray(returnType) == null) return returnType; 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 911b88739a..6286ef2706 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 @@ -5583,7 +5583,7 @@ protected ClassNode inferReturnTypeGenerics(final ClassNode receiver, final Meth } else { args.addExpression(arguments); } - return inferReturnTypeGenerics(receiver, dgm, args); + return inferReturnTypeGenerics(receiver, dgm, args, explicitTypeHints); // GRECLIPSE edit -- GROOVY-10036 } Map resolvedPlaceholders = resolvePlaceHoldersFromDeclaration(receiver, getDeclaringClass(method, arguments), method, method.isStatic()); resolvePlaceholdersFromExplicitTypeHints(method, explicitTypeHints, resolvedPlaceholders); 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 12a27ae55c..8d51f7e2cc 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 @@ -5547,7 +5547,7 @@ protected ClassNode inferReturnTypeGenerics(final ClassNode receiver, final Meth } else { args.addExpression(arguments); } - return inferReturnTypeGenerics(receiver, dgm, args); + return inferReturnTypeGenerics(receiver, dgm, args, explicitTypeHints); // GRECLIPSE edit -- GROOVY-10036 } Map resolvedPlaceholders = resolvePlaceHoldersFromDeclaration(receiver, getDeclaringClass(method, arguments), method, method.isStatic()); resolvePlaceholdersFromExplicitTypeHints(method, explicitTypeHints, resolvedPlaceholders);