Bug 98954 - Javadoc of ITypeBinding#getErasure() is wrong for array types
Summary: Javadoc of ITypeBinding#getErasure() is wrong for array types
Status: CLOSED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 RC2   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-08 10:34 EDT by Markus Keller CLA
Modified: 2005-06-10 10:29 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2005-06-08 10:34:36 EDT
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[]).
Comment 1 Philipe Mulet CLA 2005-06-08 10:36:20 EDT
+1 for RC2
Comment 2 Olivier Thomann CLA 2005-06-08 11:52:50 EDT
Jim,

Could you please cover the array type case in the erasure()? The implementation
is correct.
Comment 3 Olivier Thomann CLA 2005-06-08 12:09:20 EDT
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.
Comment 4 Jim des Rivieres CLA 2005-06-08 12:23:41 EDT
Change brings spec into line with implemented behavior.
API spec change approved for 3.1RC2.
Comment 5 Markus Keller CLA 2005-06-08 12:29:56 EDT
The updated spec is still not fully complete, since it does not mention that the
erasure has the same dimensions as the receiver.
Comment 6 Olivier Thomann CLA 2005-06-08 14:15:06 EDT
/**
	 * 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?
Comment 7 Olivier Thomann CLA 2005-06-08 14:50:01 EDT
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?
Comment 8 Jim des Rivieres CLA 2005-06-08 15:02:28 EDT
the wording is fine.
Comment 9 Olivier Thomann CLA 2005-06-09 09:36:11 EDT
Verified with N20050609-0010 + JDT/Core HEAD
Comment 10 David Audel CLA 2005-06-10 10:29:17 EDT
Verified for 3.1 RC2 using build I20050610-0010