| Summary: | [12][extract method] Does not pass the variable used in switch expression to extracted method | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Noopur Gupta <noopur_gupta> |
| Component: | UI | Assignee: | Kalyan Prasad Tatavarthi <kalyan_prasad> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | ||
| Version: | 4.11 | ||
| Target Milestone: | BETA J12 | ||
| Hardware: | All | ||
| OS: | All | ||
| See Also: |
https://git.eclipse.org/r/138710 https://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=fe49b5fe962e9d503d5c27aed3845fe49b6fb6d8 |
||
| Whiteboard: | |||
| Bug Depends on: | 545193 | ||
| Bug Blocks: | 545120 | ||
New Gerrit change created: https://git.eclipse.org/r/138710 Gerrit change https://git.eclipse.org/r/138710 was merged to [BETA_JAVA_12]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=fe49b5fe962e9d503d5c27aed3845fe49b6fb6d8 We need to add tests also after bug 545193 is resolved. |
String foo(Day day) { int x = 0; var today = switch(day){ case SATURDAY, SUNDAY: break "Weekend day"; case MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY: { var kind = "Working day"; break kind; } default: { var kind = day.name(); System.out.println(kind + x); throw new IllegalArgumentException("Invalid day: " + kind); } }; return today; } - Extract switch to a new method. The result is: ... int x = 0; var today = m(); ... private String m() { ... }