Lombok: Incorrect type in equals when using @EqualsAndHashCode

Created on 3 Jan 2017  路  2Comments  路  Source: projectlombok/lombok

Consider the following code:

import lombok.EqualsAndHashCode;

public interface DynamicType {

    interface Unloaded extends DynamicType {

    }

    class Default implements DynamicType {

        @EqualsAndHashCode(callSuper = false)
        public static class Unloaded extends Default implements DynamicType.Unloaded {

        }
    }
}

Compilation fails with error:

DynamicType.java:[11,9] reference to Unloaded is ambiguous
[ERROR] both class DynamicType.Default.Unloaded in DynamicType.Default and interface DynamicType.Unloaded in DynamicType match

If we check the generated code

...
public boolean equals(final java.lang.Object o) {
       if (o == this) return true;
       if (!(o instanceof DynamicType.Default.Unloaded)) return false;
       final Unloaded other = (Unloaded) o;
...

we can see that type name is not fully specified in cast operation. All other places of generated code use canonical class name.

Most helpful comment

Fixed in release 1.16.14. It's the 'you never encountered this bug' reference in the changelog :)

All 2 comments

Fixed in release 1.16.14. It's the 'you never encountered this bug' reference in the changelog :)

Cool, thank you!

Was this page helpful?
0 / 5 - 0 ratings