History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: IDEADEV-24167
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Normal Normal
Assignee: Bas Leijdekkers
Reporter: Serge Baranov
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
IDEA: Development

Bug in ternary to if-else auto refactoring

Created: 06 Jan 08 22:56   Updated: 07 Jan 08 23:20
Component/s: Editor. Intention Actions
Fix Version/s: Selena 7.0.3, Diana 8243

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown

Build: 7,590
Fixed in build: 8,088
Severity: Medium


 Description  « Hide
Support feedback:

There is a bug in the automatic refactoring from the ternary operator to if-else. I am using IntelliJ version 7.02. I have provided the following
class to illustrate the problem.

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);
        }
}


 All   Comments   Work Log   Change History      Sort Order:
There are no comments yet on this issue.