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/basic/GroovySimpleTests.java
+196-77
Original file line number
Diff line number
Diff line change
@@ -1014,152 +1014,271 @@ public void testClash_GRE1076_2() {
1014
1014
}
1015
1015
1016
1016
@Test
1017
-
publicvoidtestCyclicReference() {
1017
+
publicvoidtestCyclicReference1() {
1018
1018
//@formatter:off
1019
1019
String[] sources = {
1020
-
"p/B.groovy",
1021
-
"package p;\n" +
1022
-
"class B extends B<String> {\n" +
1023
-
" public static void main(String[] argv) {\n" +
1024
-
" new B();\n" +
1025
-
" print \"success\"\n" +
1020
+
"C.groovy",
1021
+
"class C extends C {\n" +
1022
+
"}\n",
1023
+
};
1024
+
//@formatter:on
1025
+
1026
+
runNegativeTest(sources,
1027
+
"----------\n" +
1028
+
"1. ERROR in C.groovy (at line 1)\n" +
1029
+
"\tclass C extends C {\n" +
1030
+
"\t ^\n" +
1031
+
"Groovy:Cycle detected: the type C cannot extend/implement itself or one of its own member types\n" +
1032
+
"----------\n");
1033
+
}
1034
+
1035
+
@Test
1036
+
publicvoidtestCyclicReference2() {
1037
+
//@formatter:off
1038
+
String[] sources = {
1039
+
"I.groovy",
1040
+
"interface I extends I {\n" +
1041
+
"}\n",
1042
+
};
1043
+
//@formatter:on
1044
+
1045
+
runNegativeTest(sources,
1046
+
"----------\n" +
1047
+
"1. ERROR in I.groovy (at line 1)\n" +
1048
+
"\tinterface I extends I {\n" +
1049
+
"\t ^\n" +
1050
+
"Groovy:Cycle detected: the type I cannot extend/implement itself or one of its own member types\n" +
1051
+
"----------\n");
1052
+
}
1053
+
1054
+
@Test
1055
+
publicvoidtestCyclicReference3() {
1056
+
//@formatter:off
1057
+
String[] sources = {
1058
+
"C.groovy",
1059
+
"class C extends C.D {\n" +
1060
+
" class D {\n" +
1026
1061
" }\n" +
1027
1062
"}\n",
1063
+
};
1064
+
//@formatter:on
1028
1065
1029
-
"p/A.java",
1030
-
"package p;\n" +
1031
-
"public class A<T> {}\n",
1066
+
runNegativeTest(sources,
1067
+
"----------\n" +
1068
+
"1. ERROR in C.groovy (at line 1)\n" +
1069
+
"\tclass C extends C.D {\n" +
1070
+
"\t ^^^\n" +
1071
+
"Groovy:Cycle detected: the type C cannot extend/implement itself or one of its own member types\n" +
1072
+
"----------\n");
1073
+
}
1074
+
1075
+
@Test// GROOVY-10124
1076
+
publicvoidtestCyclicReference4() {
1077
+
//@formatter:off
1078
+
String[] sources = {
1079
+
"C.groovy",
1080
+
"class C extends D {\n" +
1081
+
" class D {\n" +
1082
+
" }\n" +
1083
+
"}\n",
1032
1084
};
1033
1085
//@formatter:on
1034
1086
1035
1087
runNegativeTest(sources,
1036
1088
"----------\n" +
1037
-
"1. ERROR in p\\B.groovy (at line 2)\n" +
1038
-
"\tclass B extends B<String> {\n" +
1039
-
"\t ^\n" +
1040
-
"Groovy:Cyclic inheritance involving p.B in class p.B\n" +
1089
+
"1. ERROR in C.groovy (at line 1)\n" +
1090
+
"\tclass C extends D {\n" +
1091
+
"\t ^\n" +
1092
+
"Groovy:Cycle detected: the type C cannot extend/implement itself or one of its own member types\n" +
1093
+
"----------\n");
1094
+
}
1095
+
1096
+
@Test// GROOVY-10113
1097
+
publicvoidtestCyclicReference5() {
1098
+
//@formatter:off
1099
+
String[] sources = {
1100
+
"C.groovy",
1101
+
"class C<T extends T> {\n" +
1102
+
"}\n",
1103
+
};
1104
+
//@formatter:on
1105
+
1106
+
runNegativeTest(sources,
1107
+
"----------\n" +
1108
+
"1. ERROR in C.groovy (at line 1)\n" +
1109
+
"\tclass C<T extends T> {\n" +
1110
+
"\t ^\n" +
1111
+
"Groovy:Cycle detected: the type T cannot extend/implement itself or one of its own member types\n" +
1112
+
"----------\n");
1113
+
}
1114
+
1115
+
@Test
1116
+
publicvoidtestCyclicReference6() {
1117
+
//@formatter:off
1118
+
String[] sources = {
1119
+
"C.groovy",
1120
+
"class C extends C<String> {\n" +
1121
+
"}\n",
1122
+
};
1123
+
//@formatter:on
1124
+
1125
+
runNegativeTest(sources,
1041
1126
"----------\n" +
1042
-
"2. ERROR in p\\B.groovy (at line 2)\n" +
1043
-
"\tclass B extends B<String> {\n" +
1127
+
"1. ERROR in C.groovy (at line 1)\n" +
1128
+
"\tclass C extends C<String> {\n" +
1044
1129
"\t ^\n" +
1045
-
"Cycle detected: the type B cannot extend/implement itself or one of its own member types\n" +
1130
+
"Groovy:Cycle detected: the type C cannot extend/implement itself or one of its own member types\n" +
1046
1131
"----------\n");
1047
1132
}
1048
1133
1049
1134
@Test
1050
-
publicvoidtestCyclicReference_GR531() {
1135
+
publicvoidtestCyclicReference7() {
1051
1136
//@formatter:off
1052
1137
String[] sources = {
1053
-
"XXX.groovy",
1054
-
"class XXX extends XXX {\n" +
1138
+
"C.groovy",
1139
+
"class C extends D {\n" +
1140
+
"}\n",
1141
+
1142
+
"D.groovy",
1143
+
"class D extends C {\n" +
1055
1144
"}\n",
1056
1145
};
1057
1146
//@formatter:on
1058
1147
1059
1148
runNegativeTest(sources,
1060
1149
"----------\n" +
1061
-
"1. ERROR in XXX.groovy (at line 1)\n" +
1062
-
"\tclass XXX extends XXX {\n" +
1063
-
"\t ^^^\n" +
1064
-
"Groovy:Cyclic inheritance involving XXX in class XXX\n" +
1150
+
"1. ERROR in C.groovy (at line 1)\n" +
1151
+
"\tclass C extends D {\n" +
1152
+
"\t ^\n" +
1153
+
"The hierarchy of the type C is inconsistent\n" +
1154
+
"----------\n" +
1065
1155
"----------\n" +
1066
-
"2. ERROR in XXX.groovy (at line 1)\n" +
1067
-
"\tclass XXX extends XXX {\n" +
1068
-
"\t ^^^\n" +
1069
-
"Cycle detected: the type XXX cannot extend/implement itself or one of its own member types\n" +
1156
+
"1. ERROR in D.groovy (at line 1)\n" +
1157
+
"\tclass D extends C {\n" +
1158
+
"\t ^\n" +
1159
+
"Groovy:Cycle detected: a cycle exists in the type hierarchy between D and C\n" +
1070
1160
"----------\n");
1071
1161
}
1072
1162
1073
1163
@Test
1074
-
publicvoidtestCyclicReference_GR531_2() {
1164
+
publicvoidtestCyclicReference8() {
1075
1165
//@formatter:off
1076
1166
String[] sources = {
1077
-
"XXX.groovy",
1078
-
"class XXX extends XXX {\n" +
1079
-
" public static void main(String[] argv) {\n" +
1080
-
" print \"success\"\n" +
1081
-
" }\n" +
1167
+
"I.groovy",
1168
+
"interface I extends J {\n" +
1169
+
"}\n",
1170
+
1171
+
"J.groovy",
1172
+
"interface J extends I {\n" +
1082
1173
"}\n",
1083
1174
};
1084
1175
//@formatter:on
1085
1176
1086
1177
runNegativeTest(sources,
1087
1178
"----------\n" +
1088
-
"1. ERROR in XXX.groovy (at line 1)\n" +
1089
-
"\tclass XXX extends XXX {\n" +
1090
-
"\t ^^^\n" +
1091
-
"Groovy:Cyclic inheritance involving XXX in class XXX\n" +
1179
+
"1. ERROR in I.groovy (at line 1)\n" +
1180
+
"\tinterface I extends J {\n" +
1181
+
"\t ^\n" +
1182
+
"The hierarchy of the type I is inconsistent\n" +
1183
+
"----------\n" +
1092
1184
"----------\n" +
1093
-
"2. ERROR in XXX.groovy (at line 1)\n" +
1094
-
"\tclass XXX extends XXX {\n" +
1095
-
"\t^^^\n" +
1096
-
"Cycle detected: the type XXX cannot extend/implement itself or one of its own member types\n" +
1185
+
"1. ERROR in J.groovy (at line 1)\n" +
1186
+
"\tinterface J extends I {\n" +
1187
+
"\t^\n" +
1188
+
"Groovy:Cycle detected: a cycle exists in the type hierarchy between J and I\n" +
1097
1189
"----------\n");
1098
1190
}
1099
1191
1100
1192
@Test
1101
-
publicvoidtestCyclicReference_GR531_3() {
1193
+
publicvoidtestCyclicReference9() {
1102
1194
//@formatter:off
1103
1195
String[] sources = {
1104
-
"XXX.groovy",
1105
-
"class XXX extends YYY {\n" +
1106
-
" public static void main(String[] argv) {\n" +
1107
-
" print \"success\"\n" +
1196
+
"C.groovy",
1197
+
"class C extends D {\n" +
1198
+
" interface I {\n" +
1108
1199
" }\n" +
1109
1200
"}\n",
1110
-
"YYY.groovy",
1111
-
"class YYY extends XXX {\n" +
1112
-
" public static void main(String[] argv) {\n" +
1113
-
" print \"success\"\n" +
1114
-
" }\n" +
1201
+
1202
+
"D.groovy",
1203
+
"class D implements C.I {\n" +
1115
1204
"}\n",
1116
1205
};
1117
1206
//@formatter:on
1118
1207
1119
1208
runNegativeTest(sources,
1120
1209
"----------\n" +
1121
-
"1. ERROR in XXX.groovy (at line 1)\n" +
1122
-
"\tclass XXX extends YYY {\n" +
1123
-
"\t ^^^\n" +
1124
-
"The hierarchy of the type XXX is inconsistent\n" +
1125
-
"----------\n" +
1210
+
"1. ERROR in C.groovy (at line 1)\n" +
1211
+
"\tclass C extends D {\n" +
1212
+
"\t ^\n" +
1213
+
"The hierarchy of the type C is inconsistent\n" +
1126
1214
"----------\n" +
1127
-
"1. ERROR in YYY.groovy (at line 1)\n" +
1128
-
"\tclass YYY extends XXX {\n" +
1129
-
"\t ^^^\n" +
1130
-
"Groovy:Cyclic inheritance involving YYY in class YYY\n" +
1131
1215
"----------\n" +
1132
-
"2. ERROR in YYY.groovy (at line 1)\n" +
1133
-
"\tclass YYY extends XXX {\n" +
1134
-
"\t ^^^\n" +
1135
-
"Cycle detected: a cycle exists in the type hierarchy between YYY and XXX\n" +
1216
+
"1. ERROR in D.groovy (at line 1)\n" +
1217
+
"\tclass D implements C.I {\n" +
1218
+
"\t^^^\n" +
1219
+
"Groovy:Cycle detected: a cycle exists in the type hierarchy between D and C\n" +
1136
1220
"----------\n");
1137
1221
}
1138
1222
1139
-
@Test
1140
-
publicvoidtestCyclicReference_GR531_4() {
1223
+
@Test// typo that caused overflow
1224
+
publicvoidtestCyclicReference10() {
1141
1225
//@formatter:off
1142
1226
String[] sources = {
1143
-
"XXX.groovy",
1144
-
"interface XXX extends XXX {\n" +
1227
+
"A.groovy",
1228
+
"interface A extends B {\n" +
1229
+
"}\n",
1230
+
1231
+
"B.groovy",
1232
+
"class B extends A {\n" +
1145
1233
"}\n",
1146
1234
};
1147
1235
//@formatter:on
1148
1236
1149
1237
runNegativeTest(sources,
1150
1238
"----------\n" +
1151
-
"1. ERROR in XXX.groovy (at line 1)\n" +
1152
-
"\tinterface XXX extends XXX {\n" +
1153
-
"\t ^^^\n" +
1154
-
"Groovy:Cyclic inheritance involving XXX in interface XXX\n" +
1239
+
"1. ERROR in A.groovy (at line 1)\n" +
1240
+
"\tinterface A extends B {\n" +
1241
+
"\t ^\n" +
1242
+
"Groovy:You are not allowed to implement the class 'B', use extends instead.\n" +
1243
+
"----------\n" +
1155
1244
"----------\n" +
1156
-
"2. ERROR in XXX.groovy (at line 1)\n" +
1157
-
"\tinterface XXX extends XXX {\n" +
1158
-
"\t ^^^\n" +
1159
-
"Cycle detected: the type XXX cannot extend/implement itself or one of its own member types\n" +
1245
+
"1. ERROR in B.groovy (at line 1)\n" +
1246
+
"\tclass B extends A {\n" +
1247
+
"\t ^\n" +
1248
+
"Groovy:Cycle detected: a cycle exists in the type hierarchy between B and A\n" +
0 commit comments