AutoRefactor icon indicating copy to clipboard operation
AutoRefactor copied to clipboard

SimplifyExpressionRefactoring: Creates compile error

Open cal101 opened this issue 9 years ago • 2 comments

Here the diff:

-        return (equalsKeyValues(compObj)
+        return equalsKeyValues(compObj)
                 && ObjectUtil.safeEquals(name, compObj.getName())
                 // && (xxx == compObj.getXxx())
                 && (yyy == compObj.getYyy())
@@ -188,8 +187,7 @@
                 && (num == compObj.getNum())
                 // && ObjectUtil.safeEquals(name2, compObj.getName2())
                 // && ObjectUtil.safeEquals(name3, compObj.getName3())
-                // && ObjectUtil.safeEquals(copytext, compObj.getCopytext())
-                );
+                // && ObjectUtil.safeEquals(copytext, compObj.getCopytext());
     }

cal101 avatar Mar 07 '16 11:03 cal101

I think it is a bug in JDT

JnRouvignac avatar Mar 18 '16 13:03 JnRouvignac

Reduced test case:


    public boolean areEqual(Object o, Object o2) {
        return (o == o2
                // commented code
                );
    }

is wongly refactored to code that does not compile:


    public boolean areEqual(Object o, Object o2) {
        return o == o2
                // commented code;
    }

JnRouvignac avatar Mar 18 '16 22:03 JnRouvignac