### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java,v retrieving revision 1.74 diff -u -r1.74 TypeHierarchyTests.java --- src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java 15 Nov 2007 15:29:20 -0000 1.74 +++ src/org/eclipse/jdt/core/tests/model/TypeHierarchyTests.java 21 Nov 2007 16:41:29 -0000 @@ -333,7 +333,39 @@ " [in foo(X) [in Y [in X.java [in q7 [in src [in TypeHierarchy]]]]]]\n", hierarchy); } -/** +/* + * Ensure that hierarchy contains an anonymous type as a subclass of the focus type, + * if the anonymous type is created with a message send to a third type as an argument to + * the constructor. + * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=210070) + */ +public void testAnonymousType11() throws CoreException { + IType type = getCompilationUnit("TypeHierarchy/src/q8/Y210070.java").getType("Y210070"); + ITypeHierarchy hierarchy = type.newTypeHierarchy(null); + assertHierarchyEquals( + "Focus: Y210070 [in Y210070.java [in q8 [in src [in TypeHierarchy]]]]\n" + + "Super types:\n" + + " Object [in Object.class [in java.lang [in "+ getExternalJCLPathString() + "]]]\n" + + "Sub types:\n" + + " [in foo(X210070) [in Z210070 [in Z210070.java [in q8 [in src [in TypeHierarchy]]]]]]\n", + hierarchy); +} +/* + * Ensure that hierarchy contains an anonymous type as a subclass of the focus type, + * if the anonymous type is created with a problem in its constructor call. + * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=210070) + */ +public void testAnonymousType12() throws CoreException { + IType type = getCompilationUnit("TypeHierarchy/src/q8/A210070.java").getType("A210070"); + ITypeHierarchy hierarchy = type.newTypeHierarchy(null); + assertHierarchyEquals( + "Focus: A210070 [in A210070.java [in q8 [in src [in TypeHierarchy]]]]\n" + + "Super types:\n" + + " Object [in Object.class [in java.lang [in "+ getExternalJCLPathString() + "]]]\n" + + "Sub types:\n" + + " [in foo() [in A210070 [in A210070.java [in q8 [in src [in TypeHierarchy]]]]]]\n", + hierarchy); +}/** * Ensures that the superclass can be retrieved for a binary inner type. */ public void testBinaryInnerTypeGetSuperclass() throws JavaModelException { Index: workspace/TypeHierarchy/src/q8/Y210070.java =================================================================== RCS file: workspace/TypeHierarchy/src/q8/Y210070.java diff -N workspace/TypeHierarchy/src/q8/Y210070.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/TypeHierarchy/src/q8/Y210070.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,3 @@ +package q8; +public class Y210070 { +} Index: workspace/TypeHierarchy/src/q8/X210070.java =================================================================== RCS file: workspace/TypeHierarchy/src/q8/X210070.java diff -N workspace/TypeHierarchy/src/q8/X210070.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/TypeHierarchy/src/q8/X210070.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,6 @@ +package q8; +public class X210070 { + public String foo() { + return "abc"; + } +} Index: workspace/TypeHierarchy/src/q8/A210070.java =================================================================== RCS file: workspace/TypeHierarchy/src/q8/A210070.java diff -N workspace/TypeHierarchy/src/q8/A210070.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/TypeHierarchy/src/q8/A210070.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,9 @@ +package q8; +public final class A210070 { + A210070(int i) { + } + void foo() { + new A210070(12) { + }; + } +} Index: workspace/TypeHierarchy/src/q8/Z210070.java =================================================================== RCS file: workspace/TypeHierarchy/src/q8/Z210070.java diff -N workspace/TypeHierarchy/src/q8/Z210070.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/TypeHierarchy/src/q8/Z210070.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,7 @@ +package q8; +public class Z210070 { + void foo(X210070 x) { + new Y210070(x.foo()) { + }; + } +} #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java,v retrieving revision 1.75 diff -u -r1.75 HierarchyResolver.java --- model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java 15 Nov 2007 15:29:16 -0000 1.75 +++ model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java 21 Nov 2007 16:41:30 -0000 @@ -291,12 +291,26 @@ System.arraycopy(superinterfaces, 0, superinterfaces = new IType[index], 0, index); return superinterfaces; } +/* + * For all type bindings that have hierarchy problems, artificially fix their superclass/superInterfaces so that the connection + * can be made. + */ private void fixSupertypeBindings() { for (int current = this.typeIndex; current >= 0; current--) { ReferenceBinding typeBinding = this.typeBindings[current]; + if ((typeBinding.tagBits & TagBits.HierarchyHasProblems) == 0) + continue; - if (typeBinding instanceof SourceTypeBinding) { + if (typeBinding instanceof LocalTypeBinding) { + LocalTypeBinding localTypeBinding = (LocalTypeBinding) typeBinding; + QualifiedAllocationExpression allocationExpression = localTypeBinding.scope.referenceContext.allocation; + TypeReference type; + if (allocationExpression != null && (type = allocationExpression.type) != null && type.resolvedType != null) { + localTypeBinding.superclass = (ReferenceBinding) type.resolvedType; + continue; + } + } ClassScope scope = ((SourceTypeBinding) typeBinding).scope; if (scope != null) { TypeDeclaration typeDeclaration = scope.referenceContext;