| Summary: | Compiler does not detects the unreachable code | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Ankur Sharma <ankur_sharma> |
| Component: | Core | Assignee: | Ayushman Jain <amj87.iitr> |
| Status: | NEW --- | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | amj87.iitr, deepakazad, markus.kell.r |
| Version: | 3.7 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
Switching on constants is anyway kind of redundant. So IMHO, we should warn when the switch is done on a constant. Something like "Redundant switch on a constant" |
snippet switch ("one") { case "one": System.out.println("Accept"); return true; case "two": System.out.println("Unreachable"); return true; default: System.out.println("Fail"); return false; } the second case statement and the default case are unreachable. The compiler can mark them as unreachable code or show a warning that I am using switch on String constant or both :)