### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: dom/org/eclipse/jdt/core/dom/BindingResolver.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BindingResolver.java,v retrieving revision 1.47 diff -u -r1.47 BindingResolver.java --- dom/org/eclipse/jdt/core/dom/BindingResolver.java 16 Mar 2007 18:28:58 -0000 1.47 +++ dom/org/eclipse/jdt/core/dom/BindingResolver.java 24 Apr 2007 02:12:48 -0000 @@ -219,9 +219,10 @@ *
* * @param recoveredTypeBinding the recovered type binding + * @param dimensions the dimensions to add the to given type binding dimensions * @return the new type binding */ - ITypeBinding getTypeBinding(RecoveredTypeBinding recoveredTypeBinding) { + ITypeBinding getTypeBinding(RecoveredTypeBinding recoveredTypeBinding, int dimensions) { return null; } Index: dom/org/eclipse/jdt/core/dom/RecoveredTypeBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/RecoveredTypeBinding.java,v retrieving revision 1.3 diff -u -r1.3 RecoveredTypeBinding.java --- dom/org/eclipse/jdt/core/dom/RecoveredTypeBinding.java 26 Mar 2007 17:30:23 -0000 1.3 +++ dom/org/eclipse/jdt/core/dom/RecoveredTypeBinding.java 24 Apr 2007 02:12:49 -0000 @@ -55,9 +55,9 @@ } } - RecoveredTypeBinding(BindingResolver resolver, RecoveredTypeBinding typeBinding) { + RecoveredTypeBinding(BindingResolver resolver, RecoveredTypeBinding typeBinding, int dimensions) { this.innerTypeBinding = typeBinding; - this.dimensions = typeBinding.getDimensions() - 1; + this.dimensions = typeBinding.getDimensions() + dimensions; this.resolver = resolver; } @@ -65,7 +65,7 @@ * @see org.eclipse.jdt.core.dom.ITypeBinding#createArrayType(int) */ public ITypeBinding createArrayType(int dimension) { - throw new IllegalArgumentException("Cannot be called on a recovered type binding"); //$NON-NLS-1$ + return this.resolver.getTypeBinding(this, dimensions); } /* (non-Javadoc) @@ -87,7 +87,7 @@ */ public ITypeBinding getComponentType() { if (this.dimensions == 0) return null; - return this.resolver.getTypeBinding(this); + return this.resolver.getTypeBinding(this, -1); } /* (non-Javadoc) @@ -230,7 +230,7 @@ * @see org.eclipse.jdt.core.dom.ITypeBinding#getSuperclass() */ public ITypeBinding getSuperclass() { - return null; + return this.resolver.resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ } /* (non-Javadoc) @@ -240,7 +240,9 @@ if (this.referenceBinding != null) { return this.typeArguments = TypeBinding.NO_TYPE_BINDINGS; } - if (this.typeArguments != null) return typeArguments; + if (this.typeArguments != null) { + return typeArguments; + } if (this.innerTypeBinding != null) { return this.innerTypeBinding.getTypeArguments(); @@ -315,8 +317,11 @@ /* (non-Javadoc) * @see org.eclipse.jdt.core.dom.ITypeBinding#isAssignmentCompatible(org.eclipse.jdt.core.dom.ITypeBinding) */ - public boolean isAssignmentCompatible(ITypeBinding variableType) { - return false; + public boolean isAssignmentCompatible(ITypeBinding typeBinding) { + if ("java.lang.Object".equals(typeBinding.getQualifiedName())) { //$NON-NLS-1$ + return true; + } + return this.isEqualTo(typeBinding); } /* (non-Javadoc) @@ -330,7 +335,10 @@ * @see org.eclipse.jdt.core.dom.ITypeBinding#isCastCompatible(org.eclipse.jdt.core.dom.ITypeBinding) */ public boolean isCastCompatible(ITypeBinding typeBinding) { - return false; + if ("java.lang.Object".equals(typeBinding.getQualifiedName())) { //$NON-NLS-1$ + return true; + } + return this.isEqualTo(typeBinding); } /* (non-Javadoc) @@ -427,7 +435,10 @@ * @see org.eclipse.jdt.core.dom.ITypeBinding#isSubTypeCompatible(org.eclipse.jdt.core.dom.ITypeBinding) */ public boolean isSubTypeCompatible(ITypeBinding typeBinding) { - return false; + if ("java.lang.Object".equals(typeBinding.getQualifiedName())) { //$NON-NLS-1$ + return true; + } + return this.isEqualTo(typeBinding); } /* (non-Javadoc) @@ -476,7 +487,36 @@ * @see org.eclipse.jdt.core.dom.IBinding#getKey() */ public String getKey() { - return null; + StringBuffer buffer = new StringBuffer(); + buffer.append("Recovered#"); //$NON-NLS-1$ + if (this.innerTypeBinding != null) { + buffer.append("innerTypeBinding") //$NON-NLS-1$ + .append(this.innerTypeBinding.getKey()); + } else if (this.currentType != null) { + buffer.append("currentType") //$NON-NLS-1$ + .append(this.currentType.toString()); + } else if (this.referenceBinding != null) { + buffer.append("referenceBinding") //$NON-NLS-1$ + .append(this.referenceBinding.computeUniqueKey()); + } else if (variableDeclaration != null) { + buffer + .append("variableDeclaration") //$NON-NLS-1$ + .append(this.variableDeclaration.getClass()) + .append(this.variableDeclaration.getName().getIdentifier()) + .append(this.variableDeclaration.getExtraDimensions()); + } + buffer.append(this.getDimensions()); + if (this.typeArguments != null) { + buffer.append('<'); + for (int i = 0, max = this.typeArguments.length; i < max; i++) { + if (i != 0) { + buffer.append(','); + } + buffer.append(this.typeArguments[i].getKey()); + } + buffer.append('>'); + } + return String.valueOf(buffer); } /* (non-Javadoc) @@ -497,7 +537,8 @@ * @see org.eclipse.jdt.core.dom.IBinding#isEqualTo(org.eclipse.jdt.core.dom.IBinding) */ public boolean isEqualTo(IBinding other) { - return false; + if (!other.isRecovered()) return false; + return this.getKey().equals(other.getKey()); } /* (non-Javadoc) Index: dom/org/eclipse/jdt/core/dom/ITypeBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ITypeBinding.java,v retrieving revision 1.66 diff -u -r1.66 ITypeBinding.java --- dom/org/eclipse/jdt/core/dom/ITypeBinding.java 15 Mar 2007 16:06:40 -0000 1.66 +++ dom/org/eclipse/jdt/core/dom/ITypeBinding.java 24 Apr 2007 02:12:49 -0000 @@ -54,13 +54,11 @@ *If the receiver is an array binding, then the resulting dimension is the given dimension * plus the dimension of the receiver. Otherwise the resulting dimension is the given * dimension.
- *It cannot be called on a recovered binding.
* * @param dimension the given dimension * @return an array type binding * @throws IllegalArgumentException:getDeclaredModifiers
method
* should be used if the original modifiers are needed.
- * Returns 0 if this type does not represent a class, interface, enum, or annotation
- * type.
+ * Returns 0 if this type does not represent a class, an interface, an enum, an annotation
+ * type or a recovered type.
*
* @return the compiled modifiers for this type binding or 0
- * if this type does not represent a class, interface, enum, or annotation
- * type
+ * if this type does not represent a class, an interface, an enum, an annotation
+ * type or a recovered type.
* @see #getDeclaredModifiers()
*/
public int getModifiers();
@@ -369,7 +367,7 @@
* @return the binding for the package in which this class, interface,
* enum, or annotation type is declared, or null
if this type
* binding represents a primitive type, an array type, the null type,
- * a type variable, a wildcard type, a capture binding, or a recovered binding.
+ * a type variable, a wildcard type, a capture binding or a recovered type binding.
*/
public IPackageBinding getPackage();
@@ -454,8 +452,8 @@
*
* If this type binding represents an interface, an array type, a
* primitive type, the null type, a type variable, an enum type,
- * an annotation type, a wildcard type, a capture binding, or a
- * recovered binding then null
is returned.
+ * an annotation type, a wildcard type, or a capture binding then
+ * null
is returned.
*
If the receiver or the argument is a recovered type, the answer is always false.
+ *If the receiver or the argument is a recovered type, the answer is always false,
+ * unless the two types are identical or the argument is java.lang.Object
.
true
if an expression of this type can be assigned to a
@@ -641,7 +640,8 @@
* A.isCastCompatible(B)
*
*
- * If the receiver or the argument is a recovered type, the answer is always false.
+ *If the receiver or the argument is a recovered type, the answer is always false,
+ * unless the two types are identical or the argument is java.lang.Object
.
true
if this type is cast compatible with the
@@ -651,9 +651,9 @@
public boolean isCastCompatible(ITypeBinding type);
/**
- * Returns whether this type binding represents a class type.
+ * Returns whether this type binding represents a class type or a recovered binding.
*
- * @return true
if this object represents a class,
+ * @return true
if this object represents a class or a recovered binding,
* and false
otherwise
*/
public boolean isClass();
@@ -844,7 +844,8 @@
* as specified in section 4.10 of The Java Language
* Specification, Third Edition (JLS3).
*
- * If the receiver or the argument is a recovered type, the answer is always false.
+ *If the receiver or the argument is a recovered type, the answer is always false,
+ * unless the two types are identical or the argument is java.lang.Object
.
true
if this type is subtype compatible with the
Index: dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java,v
retrieving revision 1.154
diff -u -r1.154 DefaultBindingResolver.java
--- dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java 15 Mar 2007 16:06:40 -0000 1.154
+++ dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java 24 Apr 2007 02:12:48 -0000
@@ -358,17 +358,11 @@
/*
* Method declared on BindingResolver.
*/
- synchronized ITypeBinding getTypeBinding(RecoveredTypeBinding recoveredTypeBinding) {
+ synchronized ITypeBinding getTypeBinding(RecoveredTypeBinding recoveredTypeBinding, int dimensions) {
if (recoveredTypeBinding== null) {
return null;
}
- ITypeBinding binding = (ITypeBinding) this.bindingTables.compilerBindingsToASTBindings.get(recoveredTypeBinding);
- if (binding != null) {
- return binding;
- }
- binding = new RecoveredTypeBinding(this, recoveredTypeBinding);
- this.bindingTables.compilerBindingsToASTBindings.put(recoveredTypeBinding, binding);
- return binding;
+ return new RecoveredTypeBinding(this, recoveredTypeBinding, dimensions);
}
synchronized IVariableBinding getVariableBinding(org.eclipse.jdt.internal.compiler.lookup.VariableBinding variableBinding, VariableDeclaration variableDeclaration) {
@@ -1734,8 +1728,7 @@
* @param dimensions the given dimensions
* @return an array type binding with the given type binding and the given
* dimensions
- * @throws IllegalArgumentException if the type binding represents the void
type binding or if the
- * given type binding is a recovered binding
+ * @throws IllegalArgumentException if the type binding represents the void
type binding
*/
ITypeBinding resolveArrayType(ITypeBinding typeBinding, int dimensions) {
if (typeBinding.isRecovered()) throw new IllegalArgumentException("Cannot be called on a recovered type binding"); //$NON-NLS-1$
Index: dom/org/eclipse/jdt/core/dom/IBinding.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/IBinding.java,v
retrieving revision 1.32
diff -u -r1.32 IBinding.java
--- dom/org/eclipse/jdt/core/dom/IBinding.java 21 Mar 2007 17:51:08 -0000 1.32
+++ dom/org/eclipse/jdt/core/dom/IBinding.java 24 Apr 2007 02:12:48 -0000
@@ -207,6 +207,7 @@
* null
.
@@ -274,7 +275,7 @@
*
* Note that the key for annotation bindings and member value pair bindings is
* not yet implemented. This returns null
for these 2 kinds of bindings.
- * null
is also returned for recovered bindings
+ * Recovered bindings have a unique key.
*