Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to ignore wildcards in keys #1282

Open
swankjesse opened this issue Dec 6, 2019 · 2 comments
Open

Option to ignore wildcards in keys #1282

swankjesse opened this issue Dec 6, 2019 · 2 comments

Comments

@swankjesse
Copy link

swankjesse commented Dec 6, 2019

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

class Jesse {
  @Inject var tacos: List<Taco>? = null
)

is equivalent to this Java code:

class Jesse {
  @Inject List<? extends Taco> tacos;
}

Note that Kotlin’s List<Taco> is equivalent to Java’s List<? extends Taco>! 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<List<? extends Taco>>, Key<List<Taco>> 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.

@mcculls
Copy link
Contributor

mcculls commented Dec 20, 2019

Hi Jesse, I don't mind providing an extra pair of eyes (although I guess you'll need someone from Google to do a formal review)

@swankjesse
Copy link
Author

@mcculls PR is up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants