github google/dagger dagger-2.53
Dagger 2.53

latest releases: dagger-2.54, dagger-2.53.1
17 days ago

Potentially breaking changes:

@Binds methods now requires explicit nullability

New: @Binds methods must explicitly declare nullability (previously we tried to infer it from
the parameter). This change aligns the nullability behavior of @Binds with how nullability is
treated elsewhere in Dagger by requiring it to be explict at the request and declaration sites.
(4941926)

Suggested fix: If you get a failure due to this change, add the proper nullability to your @Binds method/parameter. For example:

@Module
interface MyModule {
-    @Binds fun bindToNullableImpl(impl: FooImpl): Foo
+    @Binds fun bindToNullableImpl(impl: FooImpl?): Foo?
}

Scopes are now banned on @Binds that delegate to production implementations.

New: Scoping an @Binds method that delegates to an @Produces implementation is not
allowed. The scope was ignored anyway because production bindings are implicitly scoped. (03b237f)

Suggested fix: Remove the scope annotation (since the scope was ignored, this should not be a functional change).

@Module
interface MyModule {
-    @ProductionScoped
     @Binds fun bindToProductionImpl(impl: FooImpl): Foo
}

@JvmSuppressWildcards now required on multibound map requests in KSP.

New: When requesting a multibound map, users must include @JvmSuppressWildcards on the
map's value, e.g. Map<K, @JvmSuppressWildcards V>. Note that this has always been the behavior
in KAPT, but due to a bug in the KSP implementation we accidentally matched the request without
@JvmSuppressWildcards.

Suggested fix: Unfortunately, this means users may need to add back @JvmSuppressWildcards
for multibound map requests. At the moment, KSP doesn't provide a way to determine the Kotlin type
is actually assignable to Map<K, V> without @JvmSuppressWildcards at compile time, and without
this check users could hit runtime failures when Dagger tries to cast the type to the users type.

class MyClass
@Inject constructor(
-    multiboundMap: Map<K, V>
+    multiboundMap: Map<K, @JvmSuppressWildcards V>
)

In the future, we may consider simple cases where we can guarantee that @JvmSuppressWildcards can
be elided, but that is out of scope for this release.

Remove support for Java 7

New: Dagger has officially removed support for Java 7. Oracle ended support for Java 7 in
July 2022, and since Dagger has upgraded to JDK 18, compiling with language level 7 is no longer
supported. Note that this may not break users immediately since Dagger's generated code is still
technically Java 7 compatible.

Suggested Fix: Upgrade to Java 8+ (While Dagger can still test Java 8 at the moment, it is
also deprecated as of January 2024, and we'll likely need to remove support soon).

Other changes

  • Merge pull request #4459: Permit @Multibinds with values
    that are also allowed by @IntoSet/@IntoMap. (0f936b5)
  • Restrict multibindings from providing framework types that conflict with multibinding types
    Dagger provides (e.g. @Provides @IntoMap Provider<String>). This is technically a breaking
    change but existing issues should either be for unused code or code that should have already
    broken anyway. (15a30ca)
  • Remove the ignorePrivateAndStaticInjectionForComponent compiler option.
    This compiler option is only intended for internal testing of the tck tests, and should not be
    used by clients. (dfcdc9c)
  • Upgrade Hilt Gradle Plugin min AGP version to 8.1 (18d2b26)
  • Upgrade Kotlin Metadata dependency to 2.0.0-Beta5 (9a94d19)
  • Fixes #4391: Fix gwt issue (af62f2d)
  • Add GWT dependencies for Jakarta Inject (bea926c)

Don't miss a new dagger release

NewReleases is sending notifications on new releases.