Community
Participate
Working Groups
3.7 M5 - Inline x - Expected : long much = 1; - Actual: long much = (long) 1; ---------------------------------------- package cast_in; public class Test { void x() { long x = 1; long much = x; } } ----------------------------------------
Technically, it's correct, since the line "long x = 1;" contains an implicit cast which we need to make explicit in the general case. When you try to add special handling for number literals, please take care that you don't break cases where the cast is necessary, e.g. here: long x= 0x7fffffff; long much= x * 2; Note that this is not only an issue for large numbers. It's not even safe to leave out the cast on the the literal "1": long x= 1; long much= x << 32; I guess the only safe exception we can make is in places where the inlined variable will be subject to the same implicit casting/boxing as the initializer of the original variable.
(In reply to comment #1) > I guess the only safe exception we can make is in places where the inlined > variable will be subject to the same implicit casting/boxing as the initializer > of the original variable. Yeah, I saw bug 46216. The solution for this is not trivial, and we have a quick fix to remove the unnecessary cast. So I am letting it be for now..
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.