Bug 54763 - [Compiler] Unnecessary cast not detected
Summary: [Compiler] Unnecessary cast not detected
Status: VERIFIED FIXED
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.0 M9   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-03-14 12:12 EST by zugasti CLA
Modified: 2004-05-18 13:48 EDT (History)
0 users

See Also:


Attachments
Interface cast detection (1.45 KB, patch)
2004-04-02 17:55 EST, Michael Fraenkel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description zugasti CLA 2004-03-14 12:12:18 EST
List list = (List)new ArrayList();
Comment 1 Michael Fraenkel CLA 2004-04-02 17:55:48 EST
Created attachment 9172 [details]
Interface cast detection

There were at least two places both dealing with casting to an interface which
were not detecting unnecessary casts.  Is it necessary to perform the runtime
checkcast when you know that the two types are compatible?  In one case, I left
the checkcast in and the other I removed it since I wasn't sure which was
correct.  But overall I think the idea is correct.
Comment 2 Philipe Mulet CLA 2004-04-04 09:23:49 EDT
Thanks for investigating Michael, you were on the right track. Our casting 
check was not correct; and we issued more checkcast instructions than we should 
have in this case. Fixed both class->interface and interface->interface 
scenario, and instanceof + equal expression checks.

Added regression test: CastTest#test033.
Comment 3 Philipe Mulet CLA 2004-04-04 10:05:25 EDT
Fix implemented in both HEAD and JDK_1_5 streams.
Comment 4 Olivier Thomann CLA 2004-05-18 13:48:09 EDT
Verified in 200405180816