Skip to content

Commit 04c62e5

Browse files
committed
GROOVY-10725
1 parent 5a086e6 commit 04c62e5

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

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

+18
Original file line numberDiff line numberDiff line change
@@ -6180,4 +6180,22 @@ public void testTypeChecked10701() {
61806180

61816181
runConformTest(sources, "42.0");
61826182
}
6183+
6184+
@Test
6185+
public void testTypeChecked10725() {
6186+
//@formatter:off
6187+
String[] sources = {
6188+
"Main.groovy",
6189+
"@groovy.transform.TypeChecked\n" +
6190+
"void test(List<String> strings) {\n" +
6191+
" Set<Map<String,String>> set_of_maps = []\n" +
6192+
" set_of_maps.addAll(strings.collectEntries{ [it,it.toUpperCase()] })\n" +
6193+
" print set_of_maps\n" +
6194+
"}\n" +
6195+
"test(['foo','bar'])\n",
6196+
};
6197+
//@formatter:on
6198+
6199+
runConformTest(sources, "[[foo:FOO, bar:BAR]]");
6200+
}
61836201
}

base/org.codehaus.groovy25/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -6331,7 +6331,10 @@ else if (a instanceof ListExpression) {
63316331
// and unknown generics
63326332
if (!GenericsUtils.hasUnresolvedGenerics(at)) continue;
63336333

6334-
while (!at.equals(pt) && !at.equals(OBJECT_TYPE)) {
6334+
while (!at.equals(pt)
6335+
&& !at.equals(OBJECT_TYPE)
6336+
&& !isGenericsPlaceHolderOrArrayOf(at)
6337+
&& !isGenericsPlaceHolderOrArrayOf(pt)) {
63356338
ClassNode sc = GenericsUtils.getSuperClass(at, pt);
63366339
at = applyGenericsContext(GenericsUtils.extractPlaceholders(at), sc);
63376340
}

base/org.codehaus.groovy30/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -6028,7 +6028,10 @@ else if (a instanceof ListExpression) {
60286028
// and unknown generics
60296029
if (!GenericsUtils.hasUnresolvedGenerics(at)) continue;
60306030

6031-
while (!at.equals(pt) && !at.equals(OBJECT_TYPE)) {
6031+
while (!at.equals(pt)
6032+
&& !at.equals(OBJECT_TYPE)
6033+
&& !isGenericsPlaceHolderOrArrayOf(at)
6034+
&& !isGenericsPlaceHolderOrArrayOf(pt)) {
60326035
ClassNode sc = GenericsUtils.getSuperClass(at, pt);
60336036
at = applyGenericsContext(GenericsUtils.extractPlaceholders(at), sc);
60346037
}

base/org.codehaus.groovy40/src/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -5512,7 +5512,7 @@ private void resolvePlaceholdersFromImplicitTypeHints(final ClassNode[] actuals,
55125512
// and unknown generics
55135513
if (!GenericsUtils.hasUnresolvedGenerics(at)) continue;
55145514

5515-
while (!at.equals(pt) && !isObjectType(at) && !isGenericsPlaceHolderOrArrayOf(at)) {
5515+
while (!at.equals(pt) && !isObjectType(at) && !isGenericsPlaceHolderOrArrayOf(at) && !isGenericsPlaceHolderOrArrayOf(pt)) {
55165516
at = applyGenericsContext(GenericsUtils.extractPlaceholders(at), getNextSuperClass(at, pt));
55175517
}
55185518

0 commit comments

Comments
 (0)