From 8dd19b876068629fcf4af8e2ea62801edee9b7d9 Mon Sep 17 00:00:00 2001 From: Eric Milles Date: Tue, 19 Oct 2021 14:35:44 -0500 Subject: [PATCH] GROOVY-10320 --- .../core/tests/xform/TypeCheckedTests.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/TypeCheckedTests.java b/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/TypeCheckedTests.java index 1084ac8803..4d35458b2e 100644 --- a/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/TypeCheckedTests.java +++ b/base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/TypeCheckedTests.java @@ -4126,4 +4126,39 @@ public void testTypeChecked10295() { runConformTest(sources); } + + @Test + public void testTypeChecked10320() { + //@formatter:off + String[] sources = { + "Main.groovy", + "interface I {\n" + + " T plus(T t_aka_i)\n" + + "}\n" + + "@groovy.transform.TupleConstructor(defaults=false)\n" + + "class C implements I {\n" + + " final BigDecimal n\n" + + " @Override\n" + + " C plus(C c) {\n" + + " if (!c) return this\n" + + " new C((n ?: 0.0) + (c.n ?: 0.0))\n" + + " }\n" + + "}\n" + + "@groovy.transform.TypeChecked\n" + + "def X test(List items) {\n" + + " X total = null\n" + + " for (it in items) {\n" + + " if (!total)\n" + + " total = it\n" + + " else\n" + + " total += it\n" + // Cannot call X#plus(T) with arguments [X] + " }\n" + + " total\n" + + "}\n" + + "print(test([new C(1.1), new C(2.2)]).n)\n", + }; + //@formatter:on + + runConformTest(sources, "3.3"); + } }