Bug 70243 - [1.5] no warning for unsafe cast
Summary: [1.5] no warning for unsafe cast
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.1 M1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-07-16 12:09 EDT by Adam Kiezun CLA
Modified: 2005-01-11 11:02 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Kiezun CLA 2004-07-16 12:09:36 EDT
latest 1_5 for 07/16

class A{
    void foo(){
        List<Integer> li= new ArrayList<Integer>();
        List<? extends Number> ls= li;       
        List<Number> x2= (List<Number>)ls;//unsafe
        x2.add(new Float(1.0));
        
        Integer i= li.get(0);//ClassCastException!
    }
}

the line marked //unsafe is indeed unsafe
because the assignment 2 lines below throws a CCE
Comment 1 Philipe Mulet CLA 2004-07-20 09:20:10 EDT
Tuned unsafe cast diagnosis to flag wildcard conversions as well.
Added regression test: GenericTypeTest#test253
Fixed.