### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/dom/BatchASTCreationTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/BatchASTCreationTests.java,v retrieving revision 1.79 diff -u -r1.79 BatchASTCreationTests.java --- src/org/eclipse/jdt/core/tests/dom/BatchASTCreationTests.java 24 Oct 2007 13:50:40 -0000 1.79 +++ src/org/eclipse/jdt/core/tests/dom/BatchASTCreationTests.java 12 Jun 2008 11:15:11 -0000 @@ -2150,4 +2150,34 @@ "Lp1/X;.foo()V@Lp1/MyAnnot;"); } + /* + * Ensures that a parameterized type with 2 arguments referring to the same cu that contains an anonymous type with a non-default constructor + * can be created using its key in ASTRequestor#createBindings + * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=236445 ) + */ + public void test088() throws CoreException { + assertBindingCreated( + new String[] { + "/P/A.java", + "public class A {\n" + + " public void foo(C c) {\n" + + " c.bar(B //|<---Ctrl+Space after B\n" + + " }\n" + + "}\n" + + "class B {\n" + + "}", + "/P/C.java", + "public class C {\n" + + " public void bar(B code) {\n" + + " new D(null) {}; \n" + + " }\n" + + "}\n" + + "class D {\n" + + " D(Object o) {}\n" + + "}" + }, + "LA~B;"); + } + + } #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/util/BindingKeyResolver.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/BindingKeyResolver.java,v retrieving revision 1.51 diff -u -r1.51 BindingKeyResolver.java --- model/org/eclipse/jdt/internal/core/util/BindingKeyResolver.java 27 May 2008 23:40:19 -0000 1.51 +++ model/org/eclipse/jdt/internal/core/util/BindingKeyResolver.java 12 Jun 2008 11:15:12 -0000 @@ -45,6 +45,7 @@ import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding; import org.eclipse.jdt.internal.compiler.lookup.VariableBinding; import org.eclipse.jdt.internal.compiler.lookup.WildcardBinding; +import org.eclipse.jdt.internal.compiler.util.HashtableOfObject; public class BindingKeyResolver extends BindingKeyParser { Compiler compiler; @@ -69,22 +70,25 @@ CompilationUnitDeclaration outerMostParsedUnit; - private BindingKeyResolver(BindingKeyParser parser, Compiler compiler, LookupEnvironment environment, int wildcardRank, CompilationUnitDeclaration outerMostParsedUnit) { + /* + * A hash set of the file names of already resolved units + */ + HashtableOfObject resolvedUnits; + + private BindingKeyResolver(BindingKeyParser parser, Compiler compiler, LookupEnvironment environment, int wildcardRank, CompilationUnitDeclaration outerMostParsedUnit, HashtableOfObject parsedUnits) { super(parser); this.compiler = compiler; this.environment = environment; this.wildcardRank = wildcardRank; this.outerMostParsedUnit = outerMostParsedUnit; + this.resolvedUnits = parsedUnits; } - public BindingKeyResolver(String key) { - this(key, null, null); - } - public BindingKeyResolver(String key, Compiler compiler, LookupEnvironment environment) { super(key); this.compiler = compiler; this.environment = environment; + this.resolvedUnits = new HashtableOfObject(); } /* @@ -373,9 +377,11 @@ } public void consumeTopLevelType() { + char[] fileName; this.parsedUnit = getCompilationUnitDeclaration(); - if (this.parsedUnit != null && this.compiler != null) { - this.compiler.process(this.parsedUnit, this.compiler.totalUnits+1); // noop if unit has already been resolved + if (this.parsedUnit != null && this.compiler != null && !this.resolvedUnits.containsKey(fileName = this.parsedUnit.getFileName())) { + this.compiler.process(this.parsedUnit, this.compiler.totalUnits+1); // unit is resolved only once thanks to the resolvedUnits protection + this.resolvedUnits.put(fileName, fileName); } if (this.parsedUnit == null) { this.typeBinding = getBinaryBinding(); @@ -570,7 +576,7 @@ } public BindingKeyParser newParser() { - return new BindingKeyResolver(this, this.compiler, this.environment, this.rank, this.outerMostParsedUnit == null ? this.parsedUnit : this.outerMostParsedUnit); + return new BindingKeyResolver(this, this.compiler, this.environment, this.rank, this.outerMostParsedUnit == null ? this.parsedUnit : this.outerMostParsedUnit, this.resolvedUnits); } public String toString() {