Skip to content

Commit

Permalink
GROOVY-10725
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Aug 21, 2022
1 parent 5a086e6 commit 04c62e5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6180,4 +6180,22 @@ public void testTypeChecked10701() {

runConformTest(sources, "42.0");
}

@Test
public void testTypeChecked10725() {
//@formatter:off
String[] sources = {
"Main.groovy",
"@groovy.transform.TypeChecked\n" +
"void test(List<String> strings) {\n" +
" Set<Map<String,String>> set_of_maps = []\n" +
" set_of_maps.addAll(strings.collectEntries{ [it,it.toUpperCase()] })\n" +
" print set_of_maps\n" +
"}\n" +
"test(['foo','bar'])\n",
};
//@formatter:on

runConformTest(sources, "[[foo:FOO, bar:BAR]]");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6331,7 +6331,10 @@ else if (a instanceof ListExpression) {
// and unknown generics
if (!GenericsUtils.hasUnresolvedGenerics(at)) continue;

while (!at.equals(pt) && !at.equals(OBJECT_TYPE)) {
while (!at.equals(pt)
&& !at.equals(OBJECT_TYPE)
&& !isGenericsPlaceHolderOrArrayOf(at)
&& !isGenericsPlaceHolderOrArrayOf(pt)) {
ClassNode sc = GenericsUtils.getSuperClass(at, pt);
at = applyGenericsContext(GenericsUtils.extractPlaceholders(at), sc);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6028,7 +6028,10 @@ else if (a instanceof ListExpression) {
// and unknown generics
if (!GenericsUtils.hasUnresolvedGenerics(at)) continue;

while (!at.equals(pt) && !at.equals(OBJECT_TYPE)) {
while (!at.equals(pt)
&& !at.equals(OBJECT_TYPE)
&& !isGenericsPlaceHolderOrArrayOf(at)
&& !isGenericsPlaceHolderOrArrayOf(pt)) {
ClassNode sc = GenericsUtils.getSuperClass(at, pt);
at = applyGenericsContext(GenericsUtils.extractPlaceholders(at), sc);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5512,7 +5512,7 @@ private void resolvePlaceholdersFromImplicitTypeHints(final ClassNode[] actuals,
// and unknown generics
if (!GenericsUtils.hasUnresolvedGenerics(at)) continue;

while (!at.equals(pt) && !isObjectType(at) && !isGenericsPlaceHolderOrArrayOf(at)) {
while (!at.equals(pt) && !isObjectType(at) && !isGenericsPlaceHolderOrArrayOf(at) && !isGenericsPlaceHolderOrArrayOf(pt)) {
at = applyGenericsContext(GenericsUtils.extractPlaceholders(at), getNextSuperClass(at, pt));
}

Expand Down

0 comments on commit 04c62e5

Please sign in to comment.