| Priority |
Normal |
| Type | Bug |
| State | Fixed |
| Assignee | Bas Leijdekkers |
| Subsystem | Editor. Intention Actions |
| Affected versions |
No affected versions
|
| Fixed in |
No fix versions
|
| Fixed in build |
Next build |
| Build |
7590
|
| Fixed in build |
8088
|
| Severity |
0
|
IDEA-42513 |
Bug in ternary to if-else auto refactoring |
|
|
public class ReplaceTernaryWithIfBugReport {
private Object value;
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ReplaceTernaryWithIfBugReport that = (ReplaceTernaryWithIfBugReport)o;
if (value != null ? !value.equals(that.value) : that.value != null) {
return false;
}
return true;
}
public boolean equalsAfterAutomaticRefactoring(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ReplaceTernaryWithIfBugReport that = (ReplaceTernaryWithIfBugReport)o;
// I used the "Replace ?: with if-else light-bulb refactoring on
// if (value != null ? !value.equals(that.value) : that.value != null) {
// which resulted in the following:
if (value != null) {
if (!value.equals(that.value)) {
return false;
} else if (that.value != null) {
return false;
}
}
return true;
}
public int hashCode() {
return (value != null ? value.hashCode() : 0);
}
}