Summary: | [1.5][compiler] Widening reference is possible when boxing in a cast expression | ||||||
---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Olivier Thomann <Olivier_Thomann> | ||||
Component: | Core | Assignee: | Philipe Mulet <philippe_mulet> | ||||
Status: | VERIFIED FIXED | QA Contact: | |||||
Severity: | normal | ||||||
Priority: | P3 | ||||||
Version: | 3.1 | ||||||
Target Milestone: | 3.1 M5 | ||||||
Hardware: | PC | ||||||
OS: | Windows XP | ||||||
Whiteboard: | |||||||
Attachments: |
|
Description
Olivier Thomann
2005-02-03 11:57:29 EST
Created attachment 17659 [details]
Apply on HEAD
I am running all the tests now.
With this patch, we report the cast as unnecessary. Indeed, if you remove the
cast, it compiles perfectly fine.
With this patch, everything looks good for the cast expression, but there is a side effect in the EqualExpression. The following code doesn't report an error anymore: public class X { public Object foo() { java.io.Serializable o = null; if (o == 0) return o; return this; } } The JLS3 don't require the types to be cast compatible anymore. They refer to types that need to be convertible to numeric types. java.io.Serializable is not convertible to a numeric types. Check 5.1.8 section. Forget what I said in comment 2. This was wrong. In case of reference type, the casting conversion still apply. I need to investigate what should be the fix in the cast check to handle the equality expressions. I believe the spec is a bit unprecise. It does perform numeric comparison as soon as any of the operand is a numeric type. Adjusted the implementation along this idea. Added AutoboxingTest#test089. Fixed Verified in I20050214 |