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
+4-5
Original file line number
Diff line number
Diff line change
@@ -5998,11 +5998,10 @@ public void testCompileStatic9883() {
5998
5998
5999
5999
runNegativeTest(sources,
6000
6000
"----------\n" +
6001
-
"1. ERROR in Main.groovy (at line 3)\n" +
6002
-
"\tjava.util.function.Supplier<String> p = {\n" +
6003
-
"\t ^\n" +
6004
-
"Groovy:[Static type checking] - Incompatible generic argument types. " +
6005
-
"Cannot assign java.util.function.Supplier<java.util.UUID> to: java.util.function.Supplier<java.lang.String>\n" +
6001
+
"1. ERROR in Main.groovy (at line 4)\n" +
6002
+
"\treturn java.util.UUID.randomUUID()\n" +
6003
+
"\t ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
6004
+
"Groovy:[Static type checking] - Cannot return value of type java.util.UUID for closure expecting java.lang.String\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
+49-24
Original file line number
Diff line number
Diff line change
@@ -1026,7 +1026,7 @@ public void testTypeChecked7316() {
1026
1026
"1. ERROR in Main.groovy (at line 11)\n" +
1027
1027
"\tseq()\n" +
1028
1028
"\t^^^^^\n" +
1029
-
"Groovy:[Static type checking] - Cannot return value of type #T on method returning type java.util.List<?>\n" +
1029
+
"Groovy:[Static type checking] - Cannot return value of type #T for method returning java.util.List<?>\n" +
1030
1030
"----------\n");
1031
1031
}
1032
1032
@@ -3538,27 +3538,6 @@ public void testTypeChecked10082() {
3538
3538
runConformTest(sources, "truetrue");
3539
3539
}
3540
3540
3541
-
@Test
3542
-
publicvoidtestTypeChecked10082a() {
3543
-
//@formatter:off
3544
-
String[] sources = {
3545
-
"Main.groovy",
3546
-
"@groovy.transform.TypeChecked\n" +
3547
-
"void test() {\n" +
3548
-
" Closure<String> c = {-> 42}\n" +
3549
-
"}\n",
3550
-
};
3551
-
//@formatter:on
3552
-
3553
-
runNegativeTest(sources,
3554
-
"----------\n" +
3555
-
"1. ERROR in Main.groovy (at line 3)\n" +
3556
-
"\tClosure<String> c = {-> 42}\n" +
3557
-
"\t ^^^^^^^\n" +
3558
-
"Groovy:[Static type checking] - Incompatible generic argument types. Cannot assign groovy.lang.Closure<java.lang.Integer> to: groovy.lang.Closure<java.lang.String>\n" +
3559
-
"----------\n");
3560
-
}
3561
-
3562
3541
@Test
3563
3542
publicvoidtestTypeChecked10086() {
3564
3543
//@formatter:off
@@ -3664,8 +3643,8 @@ public void testTypeChecked10091() {
3664
3643
"----------\n" +
3665
3644
"1. ERROR in Main.groovy (at line 8)\n" +
3666
3645
"\tClosure<A<Number>> x = { -> new X()}\n" +
3667
-
"\t^^^^^^^^^^^^^\n" +
3668
-
"Groovy:[Static type checking] - Incompatible generic argument types. Cannot assign groovy.lang.Closure<X> to: groovy.lang.Closure<A<java.lang.Number>>\n" +
3646
+
"\t^^^^^^^\n" +
3647
+
"Groovy:[Static type checking] - Cannot return value of type X for closure expecting A<java.lang.Number>\n" +
3669
3648
"----------\n");
3670
3649
}
3671
3650
@@ -4202,6 +4181,52 @@ public void testTypeChecked10269() {
4202
4181
"----------\n");
4203
4182
}
4204
4183
4184
+
@Test
4185
+
publicvoidtestTypeChecked10277() {
4186
+
//@formatter:off
4187
+
String[] sources = {
4188
+
"Main.groovy",
4189
+
"import java.util.function.*\n" +
4190
+
"Long foo(Closure<Long> c) {\n" +
4191
+
" c()\n" +
4192
+
"}\n" +
4193
+
"Long bar(Supplier<Long> s) {\n" +
4194
+
" s.get()\n" +
4195
+
"}\n" +
4196
+
"@groovy.transform.TypeChecked\n" +
4197
+
"void test() {\n" +
4198
+
" foo { -> false}\n" +
4199
+
" bar { -> false};\n" +
4200
+
" (Supplier<Long>) { -> false};\n" +
4201
+
" { -> false} as Supplier<Long>\n" +
4202
+
"}\n",
4203
+
};
4204
+
//@formatter:on
4205
+
4206
+
runNegativeTest(sources,
4207
+
"----------\n" +
4208
+
"1. ERROR in Main.groovy (at line 10)\n" +
4209
+
"\tfoo { -> false}\n" +
4210
+
"\t ^^^^^\n" +
4211
+
"Groovy:[Static type checking] - Cannot return value of type boolean for closure expecting java.lang.Long\n" +
4212
+
"----------\n" +
4213
+
"2. ERROR in Main.groovy (at line 11)\n" +
4214
+
"\tbar { -> false};\n" +
4215
+
"\t ^^^^^\n" +
4216
+
"Groovy:[Static type checking] - Cannot return value of type boolean for closure expecting java.lang.Long\n" +
4217
+
"----------\n" +
4218
+
"3. ERROR in Main.groovy (at line 12)\n" +
4219
+
"\t(Supplier<Long>) { -> false};\n" +
4220
+
"\t ^^^^^\n" +
4221
+
"Groovy:[Static type checking] - Cannot return value of type boolean for closure expecting java.lang.Long\n" +
4222
+
"----------\n" +
4223
+
"4. ERROR in Main.groovy (at line 13)\n" +
4224
+
"\t{ -> false} as Supplier<Long>\n" +
4225
+
"\t ^^^^^\n" +
4226
+
"Groovy:[Static type checking] - Cannot return value of type boolean for closure expecting java.lang.Long\n" +
addStaticTypeError("Cannot return value of type " + prettyPrintType(type) + " for closure expecting " + prettyPrintType(inferredReturnType), expression);
0 commit comments