Skip to content

Commit

Permalink
GROOVY-10807
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Nov 4, 2022
1 parent 69f15cb commit bea24fc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7931,4 +7931,27 @@ public void testCompileStatic10791() {

runConformTest(sources, "works");
}

@Test
public void testCompileStatic10807() {
assumeTrue(isParrotParser());

//@formatter:off
String[] sources = {
"Main.groovy",
"@groovy.transform.CompileStatic\n" +
"class C {\n" +
" public static final Comparator<String> BY_DISPLAY_NAME = Comparator.<String,String>comparing(C::getDisplayName)\n" +
" static String getDisplayName(String component) {\n" +
" return component\n" +
" }\n" +
"}\n" +
"def list = ['foo','bar','baz']\n" +
"list.sort(C.BY_DISPLAY_NAME)\n" +
"print list\n",
};
//@formatter:on

runConformTest(sources, "[bar, baz, foo]");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3239,7 +3239,8 @@ protected void inferClosureParameterTypes(final ClassNode receiver, final Expres
Expression emc = typeCheckingContext.getEnclosingMethodCall();
if (emc instanceof MethodCallExpression) {
MethodCallExpression mce = (MethodCallExpression) emc;
if (mce.getArguments() == arguments) {
if (mce.getArguments() == arguments // GROOVY-10807 ::
|| expression.getCode() == GENERATED_EMPTY_STATEMENT){
GenericsType[] typeArguments = mce.getGenericsTypes();
if (typeArguments != null) {
int n = typeParameters.length;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2979,7 +2979,8 @@ protected void inferClosureParameterTypes(final ClassNode receiver, final Expres
Expression emc = typeCheckingContext.getEnclosingMethodCall();
if (emc instanceof MethodCallExpression) {
MethodCallExpression mce = (MethodCallExpression) emc;
if (mce.getArguments() == arguments) {
if (mce.getArguments() == arguments // GROOVY-10807 ::
|| expression.getCode() == GENERATED_EMPTY_STATEMENT){
GenericsType[] typeArguments = mce.getGenericsTypes();
if (typeArguments != null) {
int n = typeParameters.length;
Expand Down

0 comments on commit bea24fc

Please sign in to comment.