Incorrect type in equals when using @EqualsAndHashCode #1274

Closed
orange-buffalo opened this Issue Jan 3, 2017 · 2 comments

Projects

None yet

2 participants

@orange-buffalo

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.

@orange-buffalo orange-buffalo referenced this issue in raphw/byte-buddy Jan 6, 2017
Merged

Issue 245 #248

@rzwitserloot
Owner

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

@orange-buffalo

Cool, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment