google / google/auto

Type use annotations on receiver not copied to generated code

Open
#732 4 comments 0 reactions 0 assignees View on GitHub
P3
Dominant language
Java
Stars
10.6k
Forks
1.2k
Avg merge
6h 32m
Merged PRs (30d)
13

Description

Consider the following example:

```java
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
public @interface TypeUseTest {
String[] value() default {};
}
```

```java
import com.google.auto.value.AutoValue;

@AutoValue
abstract class Animal {
abstract String name();
abstract int numberOfLegs();

static Builder builder() {
return new AutoValue_Animal.Builder();
}

@AutoValue.Builder
abstract static class Builder {
abstract Builder setName(@TypeUseTest({"hi"}) String value);
abstract Builder setNumberOfLegs(int value);
abstract Animal build(@TypeUseTest({"hi", "bye"}) Builder this);
}
}
```

In `AutoValue_Animal.Builder`, I see the `@TypeUseTest` annotation copied down to the implementation of `setName`. But, I do not see the `@TypeUseTest` annotation on `this` copied down for the implementation of `build`.

This may be a bit of a corner case, but it would be great if it were supported! If the maintainers are interested and can point me roughly where the code should go, I can look into opening a PR.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.