You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/StaticCompilationTests.java
+7-12
Original file line number
Diff line number
Diff line change
@@ -1764,25 +1764,20 @@ public void testCompileStatic8310() {
" [1]\n" +// List<Integer> is not compatible with Collection<Integer>; "? extends Collection<Integer>" works
1773
+
" [1]\n" +
1774
1774
" }\n" +
1775
-
"}\n",
1775
+
"}\n" +
1776
+
"print foo()\n",
1776
1777
};
1777
1778
//@formatter:on
1778
1779
1779
-
runNegativeTest(sources,
1780
-
"----------\n" +
1781
-
"1. ERROR in Main.groovy (at line 6)\n" +
1782
-
"\tbar {\n" +
1783
-
"\t^\n" +
1784
-
"Groovy:[Static type checking] - Cannot find matching method Main#bar(groovy.lang.Closure<java.util.List<java.lang.Integer>>). Please check if the declared type is correct and if the method exists.\n" +
Copy file name to clipboardExpand all lines: base-test/org.eclipse.jdt.groovy.core.tests.compiler/src/org/eclipse/jdt/groovy/core/tests/xform/TypeCheckedTests.java
+48
Original file line number
Diff line number
Diff line change
@@ -2762,6 +2762,27 @@ public void testTypeChecked10082() {
2762
2762
runConformTest(sources, "truetrue");
2763
2763
}
2764
2764
2765
+
@Test
2766
+
publicvoidtestTypeChecked10082a() {
2767
+
//@formatter:off
2768
+
String[] sources = {
2769
+
"Main.groovy",
2770
+
"@groovy.transform.TypeChecked\n" +
2771
+
"void test() {\n" +
2772
+
" Closure<String> c = {-> 42}\n" +
2773
+
"}\n",
2774
+
};
2775
+
//@formatter:on
2776
+
2777
+
runNegativeTest(sources,
2778
+
"----------\n" +
2779
+
"1. ERROR in Main.groovy (at line 3)\n" +
2780
+
"\tClosure<String> c = {-> 42}\n" +
2781
+
"\t ^^^^^^^\n" +
2782
+
"Groovy:[Static type checking] - Incompatible generic argument types. Cannot assign groovy.lang.Closure<java.lang.Integer> to: groovy.lang.Closure<java.lang.String>\n" +
2783
+
"----------\n");
2784
+
}
2785
+
2765
2786
@Test
2766
2787
publicvoidtestTypeChecked10086() {
2767
2788
//@formatter:off
@@ -2819,4 +2840,31 @@ public void testTypeChecked10088() {
2819
2840
"Groovy:[Static type checking] - Cannot assign value of type java.lang.String to variable of type java.lang.Number\n" +
2820
2841
"----------\n");
2821
2842
}
2843
+
2844
+
@Test
2845
+
publicvoidtestTypeChecked10091() {
2846
+
//@formatter:off
2847
+
String[] sources = {
2848
+
"Main.groovy",
2849
+
"class A<T> {}\n" +
2850
+
"class B extends A<Number> {}\n" +
2851
+
"class X extends A<String> {}\n" +
2852
+
"class Y<Z> extends A<Number> {}\n" +
2853
+
"@groovy.transform.TypeChecked\n" +
2854
+
"void test() {\n" +
2855
+
" Closure<A<Number>> b = { -> new B()}\n" +
2856
+
" Closure<A<Number>> x = { -> new X()}\n" +
2857
+
" Closure<A<Number>> y = { -> new Y<String>()}\n" +
2858
+
"}\n",
2859
+
};
2860
+
//@formatter:on
2861
+
2862
+
runNegativeTest(sources,
2863
+
"----------\n" +
2864
+
"1. ERROR in Main.groovy (at line 8)\n" +
2865
+
"\tClosure<A<Number>> x = { -> new X()}\n" +
2866
+
"\t ^^^^^^^^^^^^^\n" +
2867
+
"Groovy:[Static type checking] - Incompatible generic argument types. Cannot assign groovy.lang.Closure<X> to: groovy.lang.Closure<A<java.lang.Number>>\n" +
0 commit comments