frjaeger220 / google-guice

Automatically exported from code.google.com/p/google-guice
Apache License 2.0
0 stars 0 forks source link

@Provides methods don't respect null or @Nullable #366

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
They should blow up on null unless the parameter is @Nullable.

Original issue reported on code.google.com by limpbizkit on 30 Apr 2009 at 12:14

GoogleCodeExporter commented 9 years ago

Original comment by sberlin on 1 Jul 2010 at 1:53

GoogleCodeExporter commented 9 years ago
The attached patch adds support for this... but in order to do it right, it 
needs to add a few new methods to the API, so I'm attaching the patch instead 
of committing it.  Please give it a look over and let me know what you think!

The new APIs are:
  InjectionPoint.forMethod(Method, TypeLiteral) : InjectionPoint
  Binder.getProvider(Dependency<T>) : Provider<T>
  ProviderLookup(Object, Dependency<T>)
  ProviderLookup.getDependency : Dependency<T>

They are required so that ProviderMethodsModule can get providers based on a 
real dependency graph, instead of a free-standing dependency.  That lets the 
rest of Guice's internals solve nullability.  It also lets the hack to solve 
issue 482 be removed, because it's handled properly by Guice now.  (This could 
also be solved by iterating re-implementing Guice's internal nullability 
checks, but IMO this is a cleaner solution, since it removes workarounds for 
other bugs & also gives cleaner error messages.)

Original comment by sberlin on 6 Jul 2010 at 9:58

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by sberlin on 23 Nov 2010 at 1:28

GoogleCodeExporter commented 9 years ago
This has been in long enough that people have coded to this bug.  We're 
attempting to ascertain how much this is actually in effect, so if we fix it we 
don't break people.

Original comment by cgruber@google.com on 27 Aug 2012 at 6:31