### 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 20 Nov 2007 12:54:51 -0000 @@ -333,6 +333,23 @@ " [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 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); +} /** * Ensures that the superclass can be retrieved for a binary inner type. */ 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/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: compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java,v retrieving revision 1.85 diff -u -r1.85 QualifiedAllocationExpression.java --- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 2 Nov 2007 11:23:38 -0000 1.85 +++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 20 Nov 2007 12:54:52 -0000 @@ -356,6 +356,13 @@ } } + if (this.anonymousType != null && receiverType != null) { + // insert anonymous type in scope (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=210070) + scope.addAnonymousType(this.anonymousType, (ReferenceBinding) receiverType); + this.anonymousType.resolve(scope); + // do we need other checks below? + } + return this.resolvedType = receiverType; } if (this.anonymousType == null) {