Support for TYPE_USE for custom @Qualifier annotations and for the @Named one
- Dominant language
- Java
- Stars
- 12.7k
- Forks
- 1.7k
- Avg merge
- 11m
- Merged PRs (30d)
- 2
Description
Currently, `@Named` does not support `TYPE_USE` target, so the following code does not compile:
```java
...Provider<@Named("app.config") Properties>...
```
It would be great if Guice supported `TYPE_USE` for `@Qualifiers` as the qualifier seems to belong to a type rather than method/field/class.
At the same time, it might be worth recommending `TYPE_USE` as the **only** target for `@Qualifier` implementations. Of course, refactoring the current `@Named` might change a lot, so I would like to support `TYPE_USE`, and decide with `@Named` later.
See:
* https://github.com/jakartaee/inject/issues/40
* https://github.com/google/dagger/issues/4794
* Spring Framework supports `TYPE_USE` for its `@Qualifier`. Note that it supports `FIELD`, `METHOD` and so on for backward compatibility, and I think newly-created qualifier annotations should not have `FIELD`, `METHOD`, and the rest targets. `TYPE_USE` should be the right target just like [jspecify's `@Nullable`](https://github.com/jspecify/jspecify/blob/d02f3871f386f3a3b87af6710a40afa44f617805/src/main/java/org/jspecify/annotations/Nullable.java#L139)
* https://github.com/google/guice/issues/1193
Contributor guide
Assessment
This issue has not been assessed yet.