Bug 100809

Summary: [1.5] Incorrect "unnecessary cast" warning
Product: [Eclipse Project] JDT Reporter: Artur Brinkmann <artur.brinkmann>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: 3.2 M3   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Artur Brinkmann CLA 2005-06-20 09:33:12 EDT
(using RC3) In the following example code, I get the warning "Unnecessary cast
from Set<Integer> to Collection". But if I remove the cast, I get the (expected)
error "Type mismatch: cannot convert from Set<Integer> to Collection<Number>"...
so, I don't think the cast is unnecessary.

----

package test;

import java.util.*;

public class Foo {
    
    @SuppressWarnings("unchecked")
    public static void main(String[] args) {
        Set<Integer> set = new HashSet<Integer>();
        set.add(42);
        Collection<Number> collection;
        collection = (Collection) set;
        System.out.println(collection.iterator().next());
    }

}
Comment 1 Philipe Mulet CLA 2005-09-30 07:06:20 EDT
Agreed.
Comment 2 Philipe Mulet CLA 2005-09-30 12:31:33 EDT
Added GenericTypeTest#test833

*** This bug has been marked as a duplicate of 106010 ***