Skip to content

Commit 8dd19b8

Browse files
committed
GROOVY-10320
1 parent aea831c commit 8dd19b8

File tree

1 file changed

+35
-0
lines changed
  • base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform

1 file changed

+35
-0
lines changed

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4126,4 +4126,39 @@ public void testTypeChecked10295() {
41264126

41274127
runConformTest(sources);
41284128
}
4129+
4130+
@Test
4131+
public void testTypeChecked10320() {
4132+
//@formatter:off
4133+
String[] sources = {
4134+
"Main.groovy",
4135+
"interface I<T extends I> {\n" +
4136+
" T plus(T t_aka_i)\n" +
4137+
"}\n" +
4138+
"@groovy.transform.TupleConstructor(defaults=false)\n" +
4139+
"class C implements I<C> {\n" +
4140+
" final BigDecimal n\n" +
4141+
" @Override\n" +
4142+
" C plus(C c) {\n" +
4143+
" if (!c) return this\n" +
4144+
" new C((n ?: 0.0) + (c.n ?: 0.0))\n" +
4145+
" }\n" +
4146+
"}\n" +
4147+
"@groovy.transform.TypeChecked\n" +
4148+
"def <X extends I> X test(List<X> items) {\n" +
4149+
" X total = null\n" +
4150+
" for (it in items) {\n" +
4151+
" if (!total)\n" +
4152+
" total = it\n" +
4153+
" else\n" +
4154+
" total += it\n" + // Cannot call X#plus(T) with arguments [X]
4155+
" }\n" +
4156+
" total\n" +
4157+
"}\n" +
4158+
"print(test([new C(1.1), new C(2.2)]).n)\n",
4159+
};
4160+
//@formatter:on
4161+
4162+
runConformTest(sources, "3.3");
4163+
}
41294164
}

0 commit comments

Comments
 (0)