Bug 73174

Summary: Set<T>.toArray(T[] array) compilation 'broken'
Product: [Eclipse Project] JDT Reporter: mike andrews <mikea>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3    
Version: 3.0   
Target Milestone: 3.1 M2   
Hardware: PC   
OS: Windows XP   
Whiteboard:

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)
----------