ConvertSwitchToIfTest: test5 rewritten as getClass() is now pure

This commit is contained in:
Tagir Valeev
2017-05-18 14:36:52 +07:00
parent 1fccd8f503
commit f2442e32fa
2 changed files with 10 additions and 6 deletions
@@ -1,7 +1,9 @@
// "Replace 'switch' with 'if'" "true" // "Replace 'switch' with 'if'" "true"
class Test { abstract class Test {
void foo(Object e) { abstract Object getObject();
Class<?> i = e.getClass();
void foo() {
Class<?> i = getObject().getClass();
if (i.equals(RuntimeException.class)) { if (i.equals(RuntimeException.class)) {
} else if (i.equals(IOException.class)) { } else if (i.equals(IOException.class)) {
} }
@@ -1,7 +1,9 @@
// "Replace 'switch' with 'if'" "true" // "Replace 'switch' with 'if'" "true"
class Test { abstract class Test {
void foo(Object e) { abstract Object getObject();
<caret>switch(e.getClass()) {
void foo() {
<caret>switch(getObject().getClass()) {
case RuntimeException.class: case RuntimeException.class:
break; break;
case IOException.class: case IOException.class: