Project: JDT
Bug 261519 dead code warning inconsistent with "if (true)" return value
Reported: 2009-01-19 11:07:03 | Status: resolved fixed

The following gives a dead code warning in the last line, because of the "if (true)" line above it: public class Main { public static void main(String[] args) { new Main().go(); } boolean go() { if (true) return true; return true; // dead code here } } However if I comment out the dead code line then the method is marked with an error for possibly not returning a boolean value (the "if (true)" line isn't good enough). Is the "if (true)" line considered safe enough to return a value (in which case there shouldn't be an error) or not (in which case there shouldn't be a dead code warning)?

Files changed in fix:
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java