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

createInjector should take Iterable<? extends Module> instead of Iterable<Module> #143

Closed
gissuebot opened this issue Jul 7, 2014 · 3 comments

Comments

@gissuebot
Copy link

From robbie.vanbrabant on August 22, 2007 17:50:34

http://groups.google.com/group/google-guice/t/7813015f7a00f8a5 from   Johannes Schneider <johannes@familieschneider.info>
Hi,
com.google.inject.Guice#createInjector has the following signature:
public static Injector createInjector(Iterable<Module> modules)
Shouldn't that be changed to
public static Injector createInjector(Iterable<? extends Module> modules)

I have a list of my modules as static reference (usefull for testing
purposes).

Collections.unmodifiableList( Arrays.asList( new ApplicationModule(),
new SecurityModule(), new ScannerModule(), new InvoiceModule() ) )

But this line returns a List of AbstractModules (or List<? extends
Module>)....

Original issue: http://code.google.com/p/google-guice/issues/detail?id=143

@gissuebot
Copy link
Author

From johannes@familieschneider.info on August 23, 2007 01:38:55

I have created a patch that fixes this problem. It also widens the generic
collections at some other locations.
The tests still run fine so I think there shouldn't be any problem

Attachment: gist
   widening_generic_collections.patch

@gissuebot
Copy link
Author

From crazyboblee on September 09, 2007 14:19:51

Thanks for the patch. I think we want to be more flexible about what we accept, but
not so much about what we return.

Status: Fixed

@gissuebot
Copy link
Author

From johannes@familieschneider.info on September 10, 2007 08:43:46

I think returning a collection without a "?" is only useful, if someone wants to add
anything to this collection.
So in my opinion "List<? extends Foo>" is better than "List<Foo>" as return type if
the list is read only.

But this is just my opinion - do whatever you prefer.

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

No branches or pull requests

1 participant