Community
Participate
Working Groups
N20050608-0010 Javadoc of ITypeBinding#getErasure() is wrong for array typess. Array types are among "all other type bindings" and would (according to javadoc) return the identical binding. But the implementation correctly returns an array type with the same dimensions and the erasure of the original element type as element type (e.g. T[] -> Object[]).
+1 for RC2
Jim, Could you please cover the array type case in the erasure()? The implementation is correct.
Here is the updated spec. /** * Returns the erasure of this type binding. * <ul> * <li>For parameterized types ({@link #isParameterizedType()}) * - returns the binding for the corresponding generic type.</li> * <li>For raw types ({@link #isRawType()}) * - returns the binding for the corresponding generic type.</li> * <li>For wildcard types ({@link #isWildcardType()}) * - returns the binding for the upper bound if it has one and * java.lang.Object in other cases.</li> * <li>For type variables ({@link #isTypeVariable()}) * - returns the binding for the erasure of the leftmost bound * if it has bounds and java.lang.Object if it does not.</li> * <li>For captures ({@link #isCapture()}) * - returns the binding for the erasure of the leftmost bound * if it has bounds and java.lang.Object if it does not.</li> * <li>For array types ({@link #isArray()}) - returns an array type * for which the element type is the erasure of the element type * ({@link #getElementType()}) of this type binding.</li> * <li>For all other type bindings - returns the identical binding.</li> * </ul> * * @return the erasure type binding * @since 3.1 */ public ITypeBinding getErasure(); See the part about array types.
Change brings spec into line with implemented behavior. API spec change approved for 3.1RC2.
The updated spec is still not fully complete, since it does not mention that the erasure has the same dimensions as the receiver.
/** * Returns the erasure of this type binding. * <ul> * <li>For parameterized types ({@link #isParameterizedType()}) * - returns the binding for the corresponding generic type.</li> * <li>For raw types ({@link #isRawType()}) * - returns the binding for the corresponding generic type.</li> * <li>For wildcard types ({@link #isWildcardType()}) * - returns the binding for the upper bound if it has one and * java.lang.Object in other cases.</li> * <li>For type variables ({@link #isTypeVariable()}) * - returns the binding for the erasure of the leftmost bound * if it has bounds and java.lang.Object if it does not.</li> * <li>For captures ({@link #isCapture()}) * - returns the binding for the erasure of the leftmost bound * if it has bounds and java.lang.Object if it does not.</li> * <li>For array types ({@link #isArray()}) - returns an array type of * the same dimension ({@link #getDimensions()}) than this type * binding for which the element type is the erasure of the element type * ({@link #getElementType()}) of this type binding.</li> * <li>For all other type bindings - returns the identical binding.</li> * </ul> * * @return the erasure type binding * @since 3.1 */ public ITypeBinding getErasure(); is this better?
Fixed and released the following version. /** * Returns the erasure of this type binding. * <ul> * <li>For parameterized types ({@link #isParameterizedType()}) * - returns the binding for the corresponding generic type.</li> * <li>For raw types ({@link #isRawType()}) * - returns the binding for the corresponding generic type.</li> * <li>For wildcard types ({@link #isWildcardType()}) * - returns the binding for the upper bound if it has one and * java.lang.Object in other cases.</li> * <li>For type variables ({@link #isTypeVariable()}) * - returns the binding for the erasure of the leftmost bound * if it has bounds and java.lang.Object if it does not.</li> * <li>For captures ({@link #isCapture()}) * - returns the binding for the erasure of the leftmost bound * if it has bounds and java.lang.Object if it does not.</li> * <li>For array types ({@link #isArray()}) - returns an array type of * the same dimension ({@link #getDimensions()}) as this type * binding for which the element type is the erasure of the element type * ({@link #getElementType()}) of this type binding.</li> * <li>For all other type bindings - returns the identical binding.</li> * </ul> * * @return the erasure type binding * @since 3.1 */ public ITypeBinding getErasure(); Jim, could you please review for English correctness?
the wording is fine.
Verified with N20050609-0010 + JDT/Core HEAD
Verified for 3.1 RC2 using build I20050610-0010