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/TypeCheckedTests.java
+66
Original file line number
Diff line number
Diff line change
@@ -900,6 +900,72 @@ public void testTypeChecked8984a() {
900
900
"----------\n");
901
901
}
902
902
903
+
@Test
904
+
publicvoidtestTypeChecked9033() {
905
+
//@formatter:off
906
+
String[] sources = {
907
+
"Main.groovy",
908
+
"@groovy.transform.TypeChecked\n" +
909
+
"List<String> test() {\n" +
910
+
" def list = []\n" +
911
+
" list << null\n" +
912
+
" return list\n" +
913
+
"}\n",
914
+
};
915
+
//@formatter:on
916
+
917
+
runNegativeTest(sources,
918
+
"----------\n" +
919
+
"1. ERROR in Main.groovy (at line 5)\n" +
920
+
"\treturn list\n" +
921
+
"\t ^^^^\n" +
922
+
"Groovy:[Static type checking] - Incompatible generic argument types. Cannot assign java.util.List<java.lang.Object> to: java.util.List<java.lang.String>\n" +
923
+
"----------\n");
924
+
}
925
+
926
+
@Test
927
+
publicvoidtestTypeChecked9033a() {
928
+
//@formatter:off
929
+
String[] sources = {
930
+
"Main.groovy",
931
+
"@groovy.transform.TypeChecked\n" +
932
+
"void test() {\n" +
933
+
" def map = [key: []]\n" +
934
+
" map.add('foo','bar')\n" +
935
+
"}\n" +
936
+
"test()",
937
+
};
938
+
//@formatter:on
939
+
940
+
runNegativeTest(sources,
941
+
"----------\n" +
942
+
"1. ERROR in Main.groovy (at line 4)\n" +
943
+
"\tmap.add('foo','bar')\n" +
944
+
"\t^^^^^^^^^^^^^^^^^^^^\n" +
945
+
"Groovy:[Static type checking] - Cannot find matching method java.util.LinkedHashMap#add(java.lang.String, java.lang.String). Please check if the declared type is correct and if the method exists.\n" +
0 commit comments