Bug 100809 - [1.5] Incorrect "unnecessary cast" warning
Summary: [1.5] Incorrect "unnecessary cast" warning
Status: RESOLVED DUPLICATE of bug 106010
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.2 M3   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-20 09:33 EDT by Artur Brinkmann CLA
Modified: 2005-09-30 12:31 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 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 ***