Details
-
Improvement
-
Status: Closed
-
Trivial
-
Resolution: Fixed
-
None
-
None
-
None
-
Patch
Description
Currently, equals() generated by @EqualsAndHashCode looks like
class C { String a, b boolean equals(Object other) { ... ... if(!(other instanceof C)) {return false} if(this.a != other.a) {...} if(this.b != other.b) {...} ... } }
It access getters/fields of enclosing class using type Object, which is not ideal and creates a little issue for static analysis done by Groovy++.
A slightly better implementation could be:
class C { String a, b boolean equals(Object other) { ... ... if(!(other instanceof C)) {return false} C another = (C) other if(this.a != another.a) {...} if(this.b != another.b) {...} ... } }
The patch attach has been reviewed on the "dev" mailing list.