Lines 15-20
Link Here
|
15 |
|
15 |
|
16 |
import junit.framework.Test; |
16 |
import junit.framework.Test; |
17 |
|
17 |
|
|
|
18 |
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; |
18 |
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; |
19 |
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; |
19 |
|
20 |
|
20 |
public class GenericsRegressionTest extends AbstractComparableTest { |
21 |
public class GenericsRegressionTest extends AbstractComparableTest { |
Lines 1157-1160
Link Here
|
1157 |
true, |
1158 |
true, |
1158 |
customOptions); |
1159 |
customOptions); |
1159 |
} |
1160 |
} |
|
|
1161 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=334622 (private access - different packages) |
1162 |
public void test334622a() { |
1163 |
this.runNegativeTest( |
1164 |
new String[] { |
1165 |
"p/X.java", |
1166 |
"package p;\n" + |
1167 |
"public class X {\n" + |
1168 |
" private Object foo;\n" + |
1169 |
"}\n", |
1170 |
"q/Y.java", |
1171 |
"package q;\n" + |
1172 |
"import p.X;\n" + |
1173 |
"public class Y {\n" + |
1174 |
" public <T extends X> void test(T t) {\n" + |
1175 |
" System.out.println(t.foo);\n" + |
1176 |
" }\n" + |
1177 |
" Zork z;\n" + |
1178 |
"}\n" |
1179 |
}, |
1180 |
"----------\n" + |
1181 |
"1. WARNING in p\\X.java (at line 3)\n" + |
1182 |
" private Object foo;\n" + |
1183 |
" ^^^\n" + |
1184 |
"The value of the field X.foo is not used\n" + |
1185 |
"----------\n" + |
1186 |
"----------\n" + |
1187 |
"1. ERROR in q\\Y.java (at line 5)\n" + |
1188 |
" System.out.println(t.foo);\n" + |
1189 |
" ^^^\n" + |
1190 |
"The field X.foo is not visible\n" + |
1191 |
"----------\n" + |
1192 |
"2. ERROR in q\\Y.java (at line 7)\n" + |
1193 |
" Zork z;\n" + |
1194 |
" ^^^^\n" + |
1195 |
"Zork cannot be resolved to a type\n" + |
1196 |
"----------\n"); |
1197 |
} |
1198 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=334622 (private access - same package) |
1199 |
public void test334622b() { |
1200 |
this.runNegativeTest( |
1201 |
new String[] { |
1202 |
"p/X.java", |
1203 |
"package p;\n" + |
1204 |
"public class X {\n" + |
1205 |
" private Object foo;\n" + |
1206 |
"}\n", |
1207 |
"p/Y.java", |
1208 |
"package p;\n" + |
1209 |
"public class Y {\n" + |
1210 |
" public <T extends X> void test(T t) {\n" + |
1211 |
" System.out.println(t.foo);\n" + |
1212 |
" }\n" + |
1213 |
" Zork z;\n" + |
1214 |
"}\n" |
1215 |
}, |
1216 |
"----------\n" + |
1217 |
"1. WARNING in p\\X.java (at line 3)\n" + |
1218 |
" private Object foo;\n" + |
1219 |
" ^^^\n" + |
1220 |
"The value of the field X.foo is not used\n" + |
1221 |
"----------\n" + |
1222 |
"----------\n" + |
1223 |
"1. ERROR in p\\Y.java (at line 4)\n" + |
1224 |
" System.out.println(t.foo);\n" + |
1225 |
" ^^^\n" + |
1226 |
"The field X.foo is not visible\n" + |
1227 |
"----------\n" + |
1228 |
"2. ERROR in p\\Y.java (at line 6)\n" + |
1229 |
" Zork z;\n" + |
1230 |
" ^^^^\n" + |
1231 |
"Zork cannot be resolved to a type\n" + |
1232 |
"----------\n"); |
1233 |
} |
1234 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=334622 (member of type variable shouldn't contain private members of class constituting intersection type) |
1235 |
public void test334622c() { |
1236 |
this.runNegativeTest( |
1237 |
new String[] { |
1238 |
"X.java", |
1239 |
"public class X {\n" + |
1240 |
" private Object foo;\n" + |
1241 |
" public <T extends X> void test(T t) {\n" + |
1242 |
" System.out.println(t.foo);\n" + |
1243 |
" Zork z;\n" + |
1244 |
" }\n" + |
1245 |
"}\n" |
1246 |
}, |
1247 |
this.complianceLevel <= ClassFileConstants.JDK1_6 ? |
1248 |
"----------\n" + |
1249 |
"1. ERROR in X.java (at line 5)\n" + |
1250 |
" Zork z;\n" + |
1251 |
" ^^^^\n" + |
1252 |
"Zork cannot be resolved to a type\n" + |
1253 |
"----------\n" : |
1254 |
|
1255 |
// 1.7+ output. |
1256 |
"----------\n" + |
1257 |
"1. WARNING in X.java (at line 2)\n" + |
1258 |
" private Object foo;\n" + |
1259 |
" ^^^\n" + |
1260 |
"The value of the field X.foo is not used\n" + |
1261 |
"----------\n" + |
1262 |
"2. ERROR in X.java (at line 4)\n" + |
1263 |
" System.out.println(t.foo);\n" + |
1264 |
" ^^^\n" + |
1265 |
"The field X.foo is not visible\n" + |
1266 |
"----------\n" + |
1267 |
"3. ERROR in X.java (at line 5)\n" + |
1268 |
" Zork z;\n" + |
1269 |
" ^^^^\n" + |
1270 |
"Zork cannot be resolved to a type\n" + |
1271 |
"----------\n"); |
1272 |
} |
1273 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=334622 (member of type variable shouldn't contain private members of class constituting intersection type) |
1274 |
public void test334622d() { |
1275 |
this.runNegativeTest( |
1276 |
new String[] { |
1277 |
"X.java", |
1278 |
"public class X {\n" + |
1279 |
" private Object foo() { return null; }\n" + |
1280 |
" public <T extends X> void test(T t) {\n" + |
1281 |
" t.foo();\n" + |
1282 |
" Zork z;\n" + |
1283 |
" }\n" + |
1284 |
"}\n" |
1285 |
}, |
1286 |
this.complianceLevel <= ClassFileConstants.JDK1_6 ? |
1287 |
"----------\n" + |
1288 |
"1. ERROR in X.java (at line 5)\n" + |
1289 |
" Zork z;\n" + |
1290 |
" ^^^^\n" + |
1291 |
"Zork cannot be resolved to a type\n" + |
1292 |
"----------\n" : |
1293 |
|
1294 |
// 1.7+ output. |
1295 |
"----------\n" + |
1296 |
"1. ERROR in X.java (at line 4)\n" + |
1297 |
" t.foo();\n" + |
1298 |
" ^^^\n" + |
1299 |
"The method foo() from the type X is not visible\n" + |
1300 |
"----------\n" + |
1301 |
"2. ERROR in X.java (at line 5)\n" + |
1302 |
" Zork z;\n" + |
1303 |
" ^^^^\n" + |
1304 |
"Zork cannot be resolved to a type\n" + |
1305 |
"----------\n"); |
1306 |
} |
1160 |
} |
1307 |
} |