Community
Participate
Working Groups
Import the classes below and you will see that "SwitchTest" has no compiler errors, but it has a "light icon" in the line "case OS.CONST: return;" with the following tooltip text: "Type mismatch: cannot convert from int to short" public class OS { public static final int CONST = 23 * 1024; } public class SwitchTest { public short c; public static void main(String[] arguments) { short c = 1; switch (c) { case OS.CONST: return; } } }
*** This bug has been marked as a duplicate of 18175 ***
This isn't a duplicate of 18175. Moving to JDT/Core for fixing
Until field constants are part of the JavaModel, we have to live with this bug, since the compiler is only authorizing type mismatch if the constant is representable into the target type. Deferring
We want to address this for 2.1, by persisting field initialization source inside the model, for further usage - in particular for temp problems while reconciling.
2.1-M2 candidate
*** Bug 23382 has been marked as a duplicate of this bug. ***
Changed Java model to persist the initialization source. Added flag on SourceTypeConverter to compute the AST from the initialization source if needed. Changed CompilationUnitProblemFinder to use this flag.
Verified.