google / google/guice

Option to ignore wildcards in keys

Open
#1,282 2 comments 3 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
12.7k
Forks
1.7k
Avg merge
11m
Merged PRs (30d)
2

Description

Using Guice with Kotlin is annoying because Kotlin inserts implied wildcards. For example, this Kotlin code:

```
class Jesse {
@Inject var tacos: List? = null
)
```

is equivalent to this Java code:

```
class Jesse {
@Inject List tacos;
}
```

Note that Kotlin’s `List` is equivalent to Java’s `List`! And this is really annoying because it’s invisible in the source code.

I claim that nobody ever wants to differentiate between types with wildcards and similar types without. Ie. nobody uses both `Key>`, `Key>` in the same application on purpose.

I’d like to implement an opt-in feature for Guice that canonicalizes keys to strip all wildcards from their types. If I implement such a thing, is anyone interested in code reviewing? It could remove a particularly annoying stumbling block from Google’s best dependency injector.

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.