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
+13-9
Original file line number
Diff line number
Diff line change
@@ -1805,17 +1805,21 @@ public void testCompileStatic8176() {
1805
1805
String[] sources = {
1806
1806
"Main.groovy",
1807
1807
"@groovy.transform.CompileStatic\n" +
1808
-
"static <M extends Map> M merge(M to, Map from) {\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
@@ -78,7 +79,8 @@ public void testTypeChecked2() {
78
79
"1. ERROR in Main.groovy (at line 5)\n" +
79
80
"\tls.add(\'abc\')\n" +
80
81
"\t^^^^^^^^^^^^^\n" +
81
-
"Groovy:[Static type checking] - Cannot find matching method java.util.ArrayList#add(java.lang.String). Please check if the declared type is correct and if the method exists.\n" +
82
+
"Groovy:[Static type checking] - Cannot find matching method java.util.ArrayList#add(java.lang.String)." +
83
+
" Please check if the declared type is correct and if the method exists.\n" +
82
84
"----------\n");
83
85
}
84
86
@@ -823,6 +825,45 @@ public void testTypeChecked7363() {
823
825
runNegativeTest(sources, "");
824
826
}
825
827
828
+
@Test
829
+
publicvoidtestTypeChecked7720() {
830
+
//@formatter:off
831
+
String[] sources = {
832
+
"Main.groovy",
833
+
"class Consumer<T> {\n" +
834
+
" @groovy.transform.TypeChecked\n" +
835
+
" def <U> void accept(U param) {\n" +
836
+
" T local = param\n" +
837
+
" }\n" +
838
+
"}\n" +
839
+
"class Converter<T, U> {\n" +
840
+
" @groovy.transform.TypeChecked\n" +
841
+
" U convert(T param) {\n" +
842
+
" return param\n" +
843
+
" }\n" +
844
+
"}\n" +
845
+
"null\n",
846
+
};
847
+
//@formatter:on
848
+
849
+
if (!isAtLeastGroovy(40)) {
850
+
runConformTest(sources);
851
+
} else {
852
+
runNegativeTest(sources,
853
+
"----------\n" +
854
+
"1. ERROR in Main.groovy (at line 4)\n" +
855
+
"\tT local = param\n" +
856
+
"\t ^^^^^\n" +
857
+
"Groovy:[Static type checking] - Cannot assign value of type U to variable of type T\n" +
858
+
"----------\n" +
859
+
"2. ERROR in Main.groovy (at line 10)\n" +
860
+
"\treturn param\n" +
861
+
"\t ^^^^^\n" +
862
+
"Groovy:[Static type checking] - Cannot return value of type T on method returning type U\n" +
863
+
"----------\n");
864
+
}
865
+
}
866
+
826
867
@Test
827
868
publicvoidtestTypeChecked7753() {
828
869
//@formatter:off
@@ -1856,7 +1897,7 @@ public void testTypeChecked9907() {
1856
1897
1857
1898
@Test
1858
1899
publicvoidtestTypeChecked9915() {
1859
-
for (Stringtype : newString[] {"List", "Iterable", "Collection"}) {
1900
+
for (Stringtype : newString[] {"List", "Collection", "Iterable"}) {
1860
1901
//@formatter:off
1861
1902
String[] sources = {
1862
1903
"Main.groovy",
@@ -1877,6 +1918,24 @@ public void testTypeChecked9915() {
1877
1918
}
1878
1919
}
1879
1920
1921
+
@Test
1922
+
publicvoidtestTypeChecked9915a() {
1923
+
for (Stringtype : newString[] {"Set", "Collection", "Iterable"}) {
1924
+
//@formatter:off
1925
+
String[] sources = {
1926
+
"Main.groovy",
1927
+
"@groovy.transform.TypeChecked\n" +
1928
+
"class C {\n" +
1929
+
type + "<String> strings = Collections.emptySet()\n" +
1930
+
"}\n" +
1931
+
"new C()\n",
1932
+
};
1933
+
//@formatter:on
1934
+
1935
+
runConformTest(sources);
1936
+
}
1937
+
}
1938
+
1880
1939
@Test
1881
1940
publicvoidtestTypeChecked9935() {
1882
1941
for (Stringtype : newString[] {"def", "int", "Integer", "BigInteger", "BigDecimal"}) {
@@ -2556,6 +2615,34 @@ public void testTypeChecked9998b() {
2556
2615
runConformTest(sources, "null");
2557
2616
}
2558
2617
2618
+
@Test
2619
+
publicvoidtestTypeChecked10002() {
2620
+
//@formatter:off
2621
+
String[] sources = {
2622
+
"Main.groovy",
2623
+
"@groovy.transform.TypeChecked\n" +
2624
+
"void test() {\n" +
2625
+
" List<String> list = ['a','b',3]\n" +
2626
+
" Deque<String> deque = ['x','y']\n" +
2627
+
"}\n",
2628
+
};
2629
+
//@formatter:on
2630
+
2631
+
runNegativeTest(sources,
2632
+
"----------\n" +
2633
+
"1. ERROR in Main.groovy (at line 3)\n" +
2634
+
"\tList<String> list = ['a','b',3]\n" +
2635
+
"\t ^^^^^^^^^^^\n" +
2636
+
"Groovy:[Static type checking] - Incompatible generic argument types." +
2637
+
" Cannot assign java.util.ArrayList<java.io.Serializable<? extends java.lang.Object>> to: java.util.List<java.lang.String>\n" +
2638
+
"----------\n" +
2639
+
"2. ERROR in Main.groovy (at line 4)\n" +
2640
+
"\tDeque<String> deque = ['x','y']\n" +
2641
+
"\t^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
2642
+
"Groovy:[Static type checking] - Cannot assign value of type java.util.List<java.lang.String> to variable of type java.util.Deque<java.lang.String>\n" +
2643
+
"----------\n");
2644
+
}
2645
+
2559
2646
@Test
2560
2647
publicvoidtestTypeChecked10006() {
2561
2648
//@formatter:off
@@ -3281,6 +3368,50 @@ public void testTypeChecked10217() {
3281
3368
runConformTest(sources, "11");
3282
3369
}
3283
3370
3371
+
@Test
3372
+
publicvoidtestTypeChecked10220() {
3373
+
//@formatter:off
3374
+
String[] sources = {
3375
+
"Main.groovy",
3376
+
"class C<S, T extends Number> {\n" +
3377
+
"}\n" +
3378
+
"@groovy.transform.TypeChecked\n" +
3379
+
"class D<T> {\n" +
3380
+
" C<? extends T, Integer> f\n" +
3381
+
" D(C<? extends T, Integer> p) {\n" +
3382
+
" f = p\n" +
3383
+
" }\n" +
3384
+
"}\n" +
3385
+
"print(new D<String>(null).f)\n",
3386
+
};
3387
+
//@formatter:on
3388
+
3389
+
runConformTest(sources, "null");
3390
+
}
3391
+
3392
+
@Test
3393
+
publicvoidtestTypeChecked10235() {
3394
+
if (Float.parseFloat(System.getProperty("java.specification.version")) > 8)
0 commit comments