View | Details | Raw Unified | Return to bug 319885 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java (+9 lines)
Lines 1168-1173 Link Here
1168
			org.eclipse.jdt.internal.compiler.ast.TypeReference ref = ((SourceTypeBinding) superType).scope.superTypeReference;
1168
			org.eclipse.jdt.internal.compiler.ast.TypeReference ref = ((SourceTypeBinding) superType).scope.superTypeReference;
1169
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=133071
1169
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=133071
1170
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=121734
1170
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=121734
1171
			if (ref != null && ref.resolvedType == null) {
1172
				// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319885, the edges we traversed may not
1173
				// really be closing into a cycle. Cannot compare bindings yet, so use names instead.
1174
				char [] referredName = ref.getLastToken(); 
1175
				char [] sourceName = superType.sourceName();
1176
				if (!CharOperation.equals(referredName, sourceName)) {
1177
					ref = null;  // no cycle really.
1178
				}
1179
			}
1171
			if (ref != null && (ref.resolvedType == null || ((ReferenceBinding) ref.resolvedType).isHierarchyBeingActivelyConnected())) {
1180
			if (ref != null && (ref.resolvedType == null || ((ReferenceBinding) ref.resolvedType).isHierarchyBeingActivelyConnected())) {
1172
				problemReporter().hierarchyCircularity(sourceType, superType, reference);
1181
				problemReporter().hierarchyCircularity(sourceType, superType, reference);
1173
				sourceType.tagBits |= TagBits.HierarchyHasProblems;
1182
				sourceType.tagBits |= TagBits.HierarchyHasProblems;
(-)src/org/eclipse/jdt/core/tests/compiler/regression/InnerClass15Test.java (+220 lines)
Lines 139-144 Link Here
139
	"The type X is never used locally\n" + 
139
	"The type X is never used locally\n" + 
140
	"----------\n");
140
	"----------\n");
141
}
141
}
142
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319885
143
public void test005() {
144
	this.runNegativeTest(new String[] {
145
		"p1/GreenBox.java",
146
		"package p1;\n" +
147
		"import static p1.BrownBox.*;\n" +
148
		"public interface GreenBox {\n" +
149
		"    public static class Cat extends Object {}\n" +
150
		"}\n",
151
		"p1/BrownBox.java",
152
		"package p1;\n" +
153
		"import static p1.GreenBox.*;\n" +
154
		"public interface BrownBox {\n" +
155
		"    public static class BlackCat extends Cat {}\n" +
156
		"}\n",
157
	},
158
	"----------\n" + 
159
	"1. WARNING in p1\\GreenBox.java (at line 2)\n" + 
160
	"	import static p1.BrownBox.*;\n" + 
161
	"	              ^^^^^^^^^^^\n" + 
162
	"The import p1.BrownBox is never used\n" + 
163
	"----------\n");
164
}
165
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319885
166
public void test006() {
167
	this.runNegativeTest(new String[] {
168
		"p1/BrownBox.java",
169
		"package p1;\n" +
170
		"import static p1.GreenBox.*;\n" +
171
		"public interface BrownBox {\n" +
172
		"    public static class BlackCat extends Cat {}\n" +
173
		"}\n",
174
		"p1/GreenBox.java",
175
		"package p1;\n" +
176
		"import static p1.BrownBox.*;\n" +
177
		"public interface GreenBox {\n" +
178
		"    public static class Cat extends Object {}\n" +
179
		"}\n",
180
	},
181
	"----------\n" + 
182
	"1. WARNING in p1\\GreenBox.java (at line 2)\n" + 
183
	"	import static p1.BrownBox.*;\n" + 
184
	"	              ^^^^^^^^^^^\n" + 
185
	"The import p1.BrownBox is never used\n" + 
186
	"----------\n");
187
}
188
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319885
189
public void test007() {
190
	this.runNegativeTest(new String[] {
191
		"p1/BrownBox.java",
192
		"package p1;\n" +
193
		"import static p1.GreenBox.*;\n" +
194
		"public interface BrownBox {\n" +
195
		"    public static class BlackCat extends Cat {}\n" +
196
		"}\n",
197
		"p1/GreenBox.java",
198
		"package p1;\n" +
199
		"import static p1.BrownBox.*;\n" +
200
		"public interface GreenBox {\n" +
201
		"    public static class Cat extends java.lang.Object {}\n" +
202
		"}\n",
203
	},
204
	"----------\n" + 
205
	"1. WARNING in p1\\GreenBox.java (at line 2)\n" + 
206
	"	import static p1.BrownBox.*;\n" + 
207
	"	              ^^^^^^^^^^^\n" + 
208
	"The import p1.BrownBox is never used\n" + 
209
	"----------\n");
210
}
211
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319885
212
public void test008() {
213
	this.runNegativeTest(new String[] {
214
		"p1/BrownBox.java",
215
		"package p1;\n" +
216
		"import static p1.GreenBox.*;\n" +
217
		"public interface BrownBox {\n" +
218
		"    public static class BlackCat extends Cat {}\n" +
219
		"}\n",
220
		"p1/GreenBox.java",
221
		"package p1;\n" +
222
		"import static p1.BrownBox.*;\n" +
223
		"public interface GreenBox {\n" +
224
		"    public static class Cat extends BlackCat {}\n" +
225
		"}\n",
226
	},
227
	"----------\n" + 
228
	"1. ERROR in p1\\BrownBox.java (at line 4)\n" + 
229
	"	public static class BlackCat extends Cat {}\n" + 
230
	"	                    ^^^^^^^^\n" + 
231
	"The hierarchy of the type BlackCat is inconsistent\n" + 
232
	"----------\n" + 
233
	"----------\n" + 
234
	"1. ERROR in p1\\GreenBox.java (at line 4)\n" + 
235
	"	public static class Cat extends BlackCat {}\n" + 
236
	"	                                ^^^^^^^^\n" + 
237
	"Cycle detected: a cycle exists in the type hierarchy between GreenBox.Cat and BrownBox.BlackCat\n" + 
238
	"----------\n");
239
}
240
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319885
241
public void test009() {
242
	this.runNegativeTest(new String[] {
243
		"p1/GreenBox.java",
244
		"package p1;\n" +
245
		"import static p1.BrownBox.*;\n" +
246
		"public interface GreenBox {\n" +
247
		"    public static class Cat extends BlackCat {}\n" +
248
		"}\n",
249
		"p1/BrownBox.java",
250
		"package p1;\n" +
251
		"import static p1.GreenBox.*;\n" +
252
		"public interface BrownBox {\n" +
253
		"    public static class BlackCat extends Cat {}\n" +
254
		"}\n",
255
	},
256
	"----------\n" + 
257
	"1. ERROR in p1\\GreenBox.java (at line 4)\n" + 
258
	"	public static class Cat extends BlackCat {}\n" + 
259
	"	                    ^^^\n" + 
260
	"The hierarchy of the type Cat is inconsistent\n" + 
261
	"----------\n" + 
262
	"----------\n" + 
263
	"1. ERROR in p1\\BrownBox.java (at line 4)\n" + 
264
	"	public static class BlackCat extends Cat {}\n" + 
265
	"	                                     ^^^\n" + 
266
	"Cycle detected: a cycle exists in the type hierarchy between BrownBox.BlackCat and GreenBox.Cat\n" + 
267
	"----------\n");
268
}
269
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319885
270
public void test0010() {
271
	this.runNegativeTest(new String[] {
272
		"p1/GreenBox.java",
273
		"package p1;\n" +
274
		"import static p1.BrownBox.*;\n" +
275
		"interface SuperInterface {\n" +
276
		"   public static class Cat extends BlackCat {}\n" +
277
		"}\n" +
278
		"public interface GreenBox {\n" +
279
		"}\n",
280
		"p1/BrownBox.java",
281
		"package p1;\n" +
282
		"import static p1.GreenBox.*;\n" +
283
		"public interface BrownBox {\n" +
284
		"    public static class BlackCat extends Cat {}\n" +
285
		"}\n",
286
	},
287
	"----------\n" + 
288
	"1. ERROR in p1\\GreenBox.java (at line 4)\n" + 
289
	"	public static class Cat extends BlackCat {}\n" + 
290
	"	                    ^^^\n" + 
291
	"The hierarchy of the type Cat is inconsistent\n" + 
292
	"----------\n" + 
293
	"----------\n" + 
294
	"1. ERROR in p1\\BrownBox.java (at line 4)\n" + 
295
	"	public static class BlackCat extends Cat {}\n" + 
296
	"	                                     ^^^\n" + 
297
	"Cat cannot be resolved to a type\n" + 
298
	"----------\n");
299
}
300
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319885
301
public void test0011() {
302
	this.runNegativeTest(new String[] {
303
		"p1/GreenBox.java",
304
		"package p1;\n" +
305
		"import static p1.BrownBox.*;\n" +
306
		"interface SuperInterface {\n" +
307
		"   public static class Cat extends BlackCat {}\n" +
308
		"}\n" +
309
		"public interface GreenBox extends SuperInterface {\n" +
310
		"}\n",
311
		"p1/BrownBox.java",
312
		"package p1;\n" +
313
		"import static p1.GreenBox.*;\n" +
314
		"public interface BrownBox {\n" +
315
		"    public static class BlackCat extends Cat {}\n" +
316
		"}\n",
317
	},
318
	"----------\n" + 
319
	"1. ERROR in p1\\GreenBox.java (at line 4)\n" + 
320
	"	public static class Cat extends BlackCat {}\n" + 
321
	"	                    ^^^\n" + 
322
	"The hierarchy of the type Cat is inconsistent\n" + 
323
	"----------\n" + 
324
	"----------\n" + 
325
	"1. ERROR in p1\\BrownBox.java (at line 4)\n" + 
326
	"	public static class BlackCat extends Cat {}\n" + 
327
	"	                                     ^^^\n" + 
328
	"Cycle detected: a cycle exists in the type hierarchy between BrownBox.BlackCat and SuperInterface.Cat\n" + 
329
	"----------\n");
330
}
331
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=319885
332
public void test0012() {
333
	this.runNegativeTest(new String[] {
334
		"p1/GreenBox.java",
335
		"package p1;\n" +
336
		"import static p1.BrownBox.*;\n" +
337
		"interface SuperInterface {\n" +
338
		"   public static class Cat extends BlackCat {}\n" +
339
		"}\n" +
340
		"public interface GreenBox extends SuperInterface {\n" +
341
		"}\n",
342
		"p1/BrownBox.java",
343
		"package p1;\n" +
344
		"import static p1.GreenBox.*;\n" +
345
		"public interface BrownBox {\n" +
346
		"    public static class BlackCat extends GreenBox.Cat {}\n" +
347
		"}\n",
348
	},
349
	"----------\n" + 
350
	"1. ERROR in p1\\GreenBox.java (at line 4)\n" + 
351
	"	public static class Cat extends BlackCat {}\n" + 
352
	"	                    ^^^\n" + 
353
	"The hierarchy of the type Cat is inconsistent\n" + 
354
	"----------\n" + 
355
	"----------\n" + 
356
	"1. ERROR in p1\\BrownBox.java (at line 4)\n" + 
357
	"	public static class BlackCat extends GreenBox.Cat {}\n" + 
358
	"	                                     ^^^^^^^^^^^^\n" + 
359
	"Cycle detected: a cycle exists in the type hierarchy between BrownBox.BlackCat and SuperInterface.Cat\n" + 
360
	"----------\n");
361
}
142
public static Class testClass() {
362
public static Class testClass() {
143
	return InnerClass15Test.class;
363
	return InnerClass15Test.class;
144
}
364
}

Return to bug 319885