### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/ResolveTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests.java,v retrieving revision 1.76 diff -u -r1.76 ResolveTests.java --- src/org/eclipse/jdt/core/tests/model/ResolveTests.java 27 Jun 2007 13:44:21 -0000 1.76 +++ src/org/eclipse/jdt/core/tests/model/ResolveTests.java 28 Jun 2007 10:19:10 -0000 @@ -1948,7 +1948,42 @@ deleteFile(new File(jarName)); } } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=120766 +public void testDuplicateTypeDeclaration8() throws JavaModelException { + this.workingCopies = new ICompilationUnit[3]; + this.workingCopies[0] = getWorkingCopy( + "/Resolve/src/test/Test.java", + "package test;"+ + "public class Test {\n" + + " void foo() {\n" + + " test.p1.Type t = new test.p1.Type();\n" + + " }\n" + + "}\n"); + + this.workingCopies[1] = getWorkingCopy( + "/Resolve/src/test/p1/Type.java", + "package test.p1;"+ + "public class Type {\n" + + " public Type(int i) {}\n" + + "}\n"); + + this.workingCopies[2] = getWorkingCopy( + "/Resolve/src/test/p2/Type.java", + "package test.p2;"+ + "public class Type {\n" + + "}\n"); + String str = this.workingCopies[0].getSource(); + int start = str.lastIndexOf("Type"); + int length = "Type".length(); + IJavaElement[] elements = this.workingCopies[0].codeSelect(start, length, this.wcOwner); + + assertElementsEqual( + "Unexpected elements", + "Type [in [Working copy] Type.java [in test.p1 [in src [in Resolve]]]]", + elements + ); +} public void testArrayParameterInsideParent1() throws JavaModelException { ICompilationUnit cu = getCompilationUnit("Resolve", "src", "", "ResolveArrayParameterInsideParent1.java"); #P org.eclipse.jdt.core Index: codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedAllocationExpression.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedAllocationExpression.java,v retrieving revision 1.27 diff -u -r1.27 SelectionOnQualifiedAllocationExpression.java --- codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedAllocationExpression.java 28 Mar 2006 20:30:01 -0000 1.27 +++ codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedAllocationExpression.java 28 Jun 2007 10:19:13 -0000 @@ -61,11 +61,26 @@ public TypeBinding resolveType(BlockScope scope) { super.resolveType(scope); - // tolerate some error cases - if (binding == null || - !(binding.isValidBinding() || - binding.problemId() == ProblemReasons.NotVisible)) + if (binding == null) { throw new SelectionNodeFound(); + } + + // tolerate some error cases + if (!binding.isValidBinding()) { + switch (binding.problemId()) { + case ProblemReasons.NotVisible: + // visibility is ignored + break; + case ProblemReasons.NotFound: + if (resolvedType != null && resolvedType.isValidBinding()) { + throw new SelectionNodeFound(resolvedType); + } + throw new SelectionNodeFound(); + default: + throw new SelectionNodeFound(); + } + } + if (anonymousType == null) throw new SelectionNodeFound(binding);