Bug 73174 - Set<T>.toArray(T[] array) compilation 'broken'
Summary: Set<T>.toArray(T[] array) compilation 'broken'
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M2   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-09-02 14:52 EDT by mike andrews CLA
Modified: 2004-09-20 09:52 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 mike andrews CLA 2004-09-02 14:52:24 EDT
if i have an object declared as:

Set<MyClass> mySet = new HashSet<MyClass>();

then i should NOT be able to do:

mySet.toArray(new AnotherClass[1]);

but the 3.1.0 JDT compiler (Build id: 200408122000) doesn't complain. this seems
like a compilation bug! 

'AnotherClass' and 'MyClass' are in separate object hierarchies.
Comment 1 Philipe Mulet CLA 2004-09-20 09:52:42 EDT
Cannot reproduce in latest.

import java.util.HashSet;
import java.util.Set;
public class X {
	public static void main(String[] args) {
		Set<X> mySet = new HashSet<X>();
		mySet.toArray("");
	}
}

----------
1. ERROR in X.java (at line 8)
	mySet.toArray("");
	      ^^^^^^^
The method toArray() in the type Set<X> is not applicable for the arguments 
(String)
----------