Skip to content

Commit 9ce3f1d

Browse files
committed
GROOVY-10357
1 parent 453b272 commit 9ce3f1d

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

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

+22
Original file line numberDiff line numberDiff line change
@@ -5116,6 +5116,28 @@ public void testTypeChecked10351() {
51165116
runConformTest(sources);
51175117
}
51185118

5119+
@Test
5120+
public void testTypeChecked10357() {
5121+
//@formatter:off
5122+
String[] sources = {
5123+
"Main.groovy",
5124+
"import java.util.function.Function\n" +
5125+
"@groovy.transform.TypeChecked\n" +
5126+
"abstract class A {\n" +
5127+
" abstract long m(Function<Boolean,Integer> f = { Boolean b -> b ? +1 : -1 })\n" +
5128+
"}\n" +
5129+
"print new A() {\n" +
5130+
" @Override\n" +
5131+
" long m(Function<Boolean,Integer> f) {\n" +
5132+
" f.apply(true).longValue()\n" +
5133+
" }\n" +
5134+
"}.m()\n",
5135+
};
5136+
//@formatter:on
5137+
5138+
runConformTest(sources, "1");
5139+
}
5140+
51195141
@Test
51205142
public void testTypeChecked10414() {
51215143
//@formatter:off

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

+1
Original file line numberDiff line numberDiff line change
@@ -4964,6 +4964,7 @@ && isAssignment(enclosingBinaryExpression.getOperation().getType())
49644964
&& isTypeSource(expr, enclosingBinaryExpression.getRightExpression())) {
49654965
targetType = getDeclaredOrInferredType(enclosingBinaryExpression.getLeftExpression());
49664966
} else if (enclosingMethod != null
4967+
&& !enclosingMethod.isAbstract()
49674968
&& !enclosingMethod.isVoidMethod()
49684969
&& isTypeSource(expr, enclosingMethod)) {
49694970
targetType = enclosingMethod.getReturnType();

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

+1
Original file line numberDiff line numberDiff line change
@@ -4849,6 +4849,7 @@ && isAssignment(enclosingBinaryExpression.getOperation().getType())
48494849
&& isTypeSource(expr, enclosingBinaryExpression.getRightExpression())) {
48504850
targetType = getDeclaredOrInferredType(enclosingBinaryExpression.getLeftExpression());
48514851
} else if (enclosingMethod != null
4852+
&& !enclosingMethod.isAbstract()
48524853
&& !enclosingMethod.isVoidMethod()
48534854
&& isTypeSource(expr, enclosingMethod)) {
48544855
targetType = enclosingMethod.getReturnType();

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

+1
Original file line numberDiff line numberDiff line change
@@ -4212,6 +4212,7 @@ && isAssignment(enclosingExpression.getOperation().getType())
42124212
&& isTypeSource(expr, enclosingExpression.getRightExpression())) {
42134213
targetType = getDeclaredOrInferredType(enclosingExpression.getLeftExpression());
42144214
} else if (enclosingMethod != null
4215+
&& !enclosingMethod.isAbstract()
42154216
&& !enclosingMethod.isVoidMethod()
42164217
&& isTypeSource(expr, enclosingMethod)) {
42174218
targetType = enclosingMethod.getReturnType();

0 commit comments

Comments
 (0)