| Summary: | [extract local] 'Extract to local variable' refactoring produces incorrect code | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Ankur Sharma <ankur_sharma> |
| Component: | UI | Assignee: | JDT-UI-Inbox <jdt-ui-inbox> |
| Status: | CLOSED DUPLICATE | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | daniel_megert, deepakazad |
| Version: | 3.7 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
> 1. the statement 'String string2 = "two";' should be placed outside the scope > of Switch Makes sense. > 2. The string "two" should have been replaced by string2 variable (even though > that is wrong and would have compile error) This is bug 100871. *** This bug has been marked as a duplicate of bug 100871 *** Note that the declaration was put at the right location in 3.3 and older. |
Snippet switch (string) { case "one": System.out.println("Accept"); return true; case "two": System.out.println("Unsure"); return true; default: System.out.println("Fail"); return false; } 1. Select the string "two" in second case statement 2. Press Ctrl + 1 and invoke extract to local variable The result is switch (string) { case "one": System.out.println("Accept"); return true; String string2 = "two"; case "two": System.out.println("Unsure"); return true; default: System.out.println("Fail"); return false; } problem: 1. the statement 'String string2 = "two";' should be placed outside the scope of Switch 2. The string "two" should have been replaced by string2 variable (even though that is wrong and would have compile error)