Skip to content

Annotations from the parameter of equals(Object) to its implementation are not being copied. #612

Description

@usmanakram232

As, stated in release notes, I expected the parameter annotation for equal method to be copied to implementation. As, perilously discussed in 579,

I tried following approaches, one discussed in previous issue and other by defining the annotation in class.

Trying org.checkerframework.checker.nullness.qual.Nullable

@AutoValue
public abstract class Play {
  abstract public String game();
  abstract public long gameId();

  public static Play createPlayWith(String game, long gameId){
    return new AutoValue_Play(game, gameId);
  }
  
  @Override abstract public boolean equals(@Nullable Object o);
}

Trying with defined @interface Nullable {}

@AutoValue
@AutoValue.CopyAnnotations
public abstract class Foo {
  abstract public String bar();

  public static Foo createFooWith(String bar){
    return new AutoValue_Foo(bar);
  }
  @Target(ElementType.TYPE_USE)
  @Retention(RetentionPolicy.RUNTIME)
  public @interface Nullable {}

  @Override abstract public boolean equals(@Nullable Object x);
}

Both of these abstract classes, with parameter annotation had no affect on implementation of equal(Object o):

@Override
  public boolean equals(Object o) {
 ...
}

Sample maven project

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions