Skip to content

Commit

Permalink
GROOVY-10036
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Apr 14, 2021
1 parent eb77114 commit 51e7349
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,29 @@ public void testDGM11() {
assertExprType(contents, "index", "java.lang.Integer");
}

@Test
public void testDGM11a() {
//@formatter:off
String contents =
"def map = ['x'].<String,Object,String>collectEntries { [it, it.size()] }\n";
//@formatter:on
assertExprType(contents, "it", "java.lang.String");
assertExprType(contents, "map", "java.util.Map<java.lang.String,java.lang.Object>");
}

@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'].<String,Object,String>collectEntries { [it, it.size()] }\n" +
"}\n";
//@formatter:on
assertExprType(contents, "it", "java.lang.String");
assertExprType(contents, "map", "java.util.Map<java.lang.String,java.lang.Object>");
}

@Test
public void testDGM12() {
//@formatter:off
Expand Down Expand Up @@ -469,8 +492,7 @@ public void testDGM42() {
assertExprType(contents, "it", "java.lang.String");
}

@Test @Ignore("ClosureParams states 'List<String>' or 'String[]', but " +
"runtime allows for destructuring if number of elements fits into params")
@Test @Ignore("ClosureParams states 'List<String>' or 'String[]', but runtime allows for destructuring if number of elements fits into params")
public void testDGM43() {
//@formatter:off
String contents =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<GenericsTypeName, GenericsType> resolvedPlaceholders = resolvePlaceHoldersFromDeclaration(receiver, getDeclaringClass(method, arguments), method, method.isStatic());
resolvePlaceholdersFromExplicitTypeHints(method, explicitTypeHints, resolvedPlaceholders);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<GenericsTypeName, GenericsType> resolvedPlaceholders = resolvePlaceHoldersFromDeclaration(receiver, getDeclaringClass(method, arguments), method, method.isStatic());
resolvePlaceholdersFromExplicitTypeHints(method, explicitTypeHints, resolvedPlaceholders);
Expand Down

0 comments on commit 51e7349

Please sign in to comment.