View | Details | Raw Unified | Return to bug 215681
Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java (-4 / +12 lines)
Lines 328-335 Link Here
328
				if (superclass instanceof ProblemReferenceBinding) {
328
				if (superclass instanceof ProblemReferenceBinding) {
329
					superclass = ((ProblemReferenceBinding) superclass).closestMatch();
329
					superclass = ((ProblemReferenceBinding) superclass).closestMatch();
330
				}
330
				}
331
				if (superclass != null) 
331
				if (superclass != null) {
332
					((SourceTypeBinding) typeBinding).superclass = (ReferenceBinding) superclass;
332
					// ensure we are not creating a cycle (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=215681 )
333
					if (!(subTypeOfType((ReferenceBinding) superclass, typeBinding))) {
334
						((SourceTypeBinding) typeBinding).superclass = (ReferenceBinding) superclass;
335
					}
336
				}
333
	
337
	
334
				TypeReference[] superInterfaces = typeDeclaration == null ? null : typeDeclaration.superInterfaces;
338
				TypeReference[] superInterfaces = typeDeclaration == null ? null : typeDeclaration.superInterfaces;
335
				int length;
339
				int length;
Lines 341-348 Link Here
341
						ReferenceBinding superInterface = (ReferenceBinding) superInterfaces[i].resolvedType;
345
						ReferenceBinding superInterface = (ReferenceBinding) superInterfaces[i].resolvedType;
342
						if (superInterface instanceof ProblemReferenceBinding)
346
						if (superInterface instanceof ProblemReferenceBinding)
343
							superInterface = superInterface.closestMatch();
347
							superInterface = superInterface.closestMatch();
344
						if (superInterface != null)
348
						if (superInterface != null) {
345
							interfaceBindings[index++] = superInterface;
349
							// ensure we are not creating a cycle (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=215681 )
350
							if (!(subTypeOfType(superInterface, typeBinding))) {
351
								interfaceBindings[index++] = superInterface;
352
							}
353
						}
346
					}
354
					}
347
					if (index < length)
355
					if (index < length)
348
						System.arraycopy(interfaceBindings, 0, interfaceBindings = new ReferenceBinding[index], 0 , index);
356
						System.arraycopy(interfaceBindings, 0, interfaceBindings = new ReferenceBinding[index], 0 , index);
(-)src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java (+68 lines)
Lines 934-939 Link Here
934
		deleteFile("/TypeHierarchy15/src/X_140340.java");
934
		deleteFile("/TypeHierarchy15/src/X_140340.java");
935
	}
935
	}
936
}
936
}
937
/*
938
 * Ensures that no cycle is created in a hierarchy with 2 types with same simple names and errors 
939
 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=215681 )
940
 */
941
public void testGeneric11() throws CoreException {
942
	try {
943
		createFolder("/TypeHierarchy15/src/p215681");
944
		createFile(
945
			"/TypeHierarchy15/src/p215681/A_215681.java", 
946
			"package p215681;\r\n" + 
947
			"public class A_215681<E> {\n" + 
948
			"}"
949
		);
950
		createFolder("/TypeHierarchy15/src/q215681");
951
		createFile(
952
			"/TypeHierarchy15/src/q215681/A_215681.java", 
953
			"package q215681;\n" + 
954
			"import p215681.A_215681;\n" + 
955
			"public class A_215681 extends A_215681<Object> {\n" + 
956
			"}"
957
		);
958
		IType type = getCompilationUnit("/TypeHierarchy15/src/q215681/A_215681.java").getType("A_215681");
959
		ITypeHierarchy hierarchy = type.newTypeHierarchy(null);
960
		assertHierarchyEquals(
961
			"Focus: A_215681 [in A_215681.java [in q215681 [in src [in TypeHierarchy15]]]]\n" + 
962
			"Super types:\n" + 
963
			"Sub types:\n",
964
			hierarchy
965
		);
966
	} finally {
967
		deleteFolder("/TypeHierarchy15/src/p215681");
968
		deleteFolder("/TypeHierarchy15/src/q215681");
969
	}
970
}
971
/*
972
 * Ensures that no cycle is created in a hierarchy with 2 types with same simple names and errors 
973
 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=215681 )
974
 */
975
public void testGeneric12() throws CoreException {
976
	try {
977
		createFolder("/TypeHierarchy15/src/p215681");
978
		createFile(
979
			"/TypeHierarchy15/src/p215681/A_215681.java", 
980
			"package p215681;\r\n" + 
981
			"public interface A_215681<E> {\n" + 
982
			"}"
983
		);
984
		createFolder("/TypeHierarchy15/src/q215681");
985
		createFile(
986
			"/TypeHierarchy15/src/q215681/A_215681.java", 
987
			"package q215681;\n" + 
988
			"import p215681.A_215681;\n" + 
989
			"public interface A_215681 extends A_215681<Object> {\n" + 
990
			"}"
991
		);
992
		IType type = getCompilationUnit("/TypeHierarchy15/src/q215681/A_215681.java").getType("A_215681");
993
		ITypeHierarchy hierarchy = type.newTypeHierarchy(null);
994
		assertHierarchyEquals(
995
			"Focus: A_215681 [in A_215681.java [in q215681 [in src [in TypeHierarchy15]]]]\n" + 
996
			"Super types:\n" + 
997
			"Sub types:\n",
998
			hierarchy
999
		);
1000
	} finally {
1001
		deleteFolder("/TypeHierarchy15/src/p215681");
1002
		deleteFolder("/TypeHierarchy15/src/q215681");
1003
	}
1004
}
937
/**
1005
/**
938
 * Ensures the correctness of all classes in a type hierarchy based on a region.
1006
 * Ensures the correctness of all classes in a type hierarchy based on a region.
939
 */
1007
 */

Return to bug 215681