mirror of
https://github.com/google/guice.git
synced 2026-10-19 16:16:21 +00:00
This doesn't change any Guice behavior; it just lets nullness checkers (like Kotlin and the Checker Framework) allow you to bind to such providers more easily. Guice's handling of `null` is not entirely principled, and this CL doesn't attempt to "solve" that, nor does it attempt to thoroughly annotate for nullness, let alone enable a nullness checker for the Guice codebase. Rather, it aims only to remove a restriction that I don't think is serving any particular purpose and that no on "intended"; I think it just kind of happened because the Checker Framework treats unannotated code leniently and strictly at different times, and this happens to be one of the strict cases. (We might also have once had the hope of cracking down on injection of `null`?) The immediate motivation for this CL is https://github.com/google/inject-common/pull/26: Soon, nullness checkers will know that `Providers.of(null)` returns *gasp* a `Provider` that can return `null`. That makes `bind(Foo.class).to(Providers.of(null))` an error. This CL lets those callers continue to compile. PiperOrigin-RevId: 734755975