Skip to content

Commit

Permalink
GROOVY-10357
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Mar 14, 2022
1 parent 453b272 commit 9ce3f1d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5116,6 +5116,28 @@ public void testTypeChecked10351() {
runConformTest(sources);
}

@Test
public void testTypeChecked10357() {
//@formatter:off
String[] sources = {
"Main.groovy",
"import java.util.function.Function\n" +
"@groovy.transform.TypeChecked\n" +
"abstract class A {\n" +
" abstract long m(Function<Boolean,Integer> f = { Boolean b -> b ? +1 : -1 })\n" +
"}\n" +
"print new A() {\n" +
" @Override\n" +
" long m(Function<Boolean,Integer> f) {\n" +
" f.apply(true).longValue()\n" +
" }\n" +
"}.m()\n",
};
//@formatter:on

runConformTest(sources, "1");
}

@Test
public void testTypeChecked10414() {
//@formatter:off
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4964,6 +4964,7 @@ && isAssignment(enclosingBinaryExpression.getOperation().getType())
&& isTypeSource(expr, enclosingBinaryExpression.getRightExpression())) {
targetType = getDeclaredOrInferredType(enclosingBinaryExpression.getLeftExpression());
} else if (enclosingMethod != null
&& !enclosingMethod.isAbstract()
&& !enclosingMethod.isVoidMethod()
&& isTypeSource(expr, enclosingMethod)) {
targetType = enclosingMethod.getReturnType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4849,6 +4849,7 @@ && isAssignment(enclosingBinaryExpression.getOperation().getType())
&& isTypeSource(expr, enclosingBinaryExpression.getRightExpression())) {
targetType = getDeclaredOrInferredType(enclosingBinaryExpression.getLeftExpression());
} else if (enclosingMethod != null
&& !enclosingMethod.isAbstract()
&& !enclosingMethod.isVoidMethod()
&& isTypeSource(expr, enclosingMethod)) {
targetType = enclosingMethod.getReturnType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4212,6 +4212,7 @@ && isAssignment(enclosingExpression.getOperation().getType())
&& isTypeSource(expr, enclosingExpression.getRightExpression())) {
targetType = getDeclaredOrInferredType(enclosingExpression.getLeftExpression());
} else if (enclosingMethod != null
&& !enclosingMethod.isAbstract()
&& !enclosingMethod.isVoidMethod()
&& isTypeSource(expr, enclosingMethod)) {
targetType = enclosingMethod.getReturnType();
Expand Down

0 comments on commit 9ce3f1d

Please sign in to comment.