Skip to content

v0.6.2

Compare
Choose a tag to compare
@evant evant released this 28 Aug 07:27
· 84 commits to main since this release
v0.6.2

[0.6.2] 2023-08-28

Changed

  • Updated kotlin to 1.9.0
  • If a dependency's scope is not found on the component providing it, a better error message is given.
  • Adding a @Provides annotation on an abstract fun or val will now warn that it has no effect.
  • When overriding a method the parent is checked to see if it has a @Provides annotation. This makes the example in
    the README actually work:
    @NetworkScope abstract class NetworkComponent {
      @NetworkScope @Provides abstract fun api(): Api
    }  
    @Component abstract class RealNetworkComponent : NetworkComponent() {
      // This is now treated as a @Provides even if not annotated directly
      override fun api(): Api = RealApi()
    }

Fixed

  • Typealiases are treated as separate types in multibinding. This is consistent with other
    uses of typealiases.

    For example:

    typealias MyString = String
    
    @Component abstract class MyComponent {
      abstract val stringItems: Set<String>
      abstract val myStringItems: Set<MyString>
    
      @Provides @IntoSet fun stringValue1(): String = "string"
    
      @Provides @IntoSet fun stringValue2(): MyString = "myString"
    }

    stringItems will contain {"string"} and myStringItems will contain {"myString"}.

  • Lambda types now work in set multibindings.

    @Component abstract class MyComponent {
      abstract val lambdaSet: Set<() -> String>
    
      @Provides @IntoSet fun lambda1(): () -> String = { "one" }
    
      @Provides @IntoSet fun lambda2(): () -> String = { "two" }
    }
  • Assisted injection no longer works with scopes or cycles. These two cases would over-cache the instance, ignoring the
    assisted arguments. They now throw an error instead.

     // now throws cycle error when providing
    @Inject class AssistedCycle(val factory: (Int) -> AssistedCycle, @Assisted val arg: Int)
    // now throws error when providing
    @MyScope @Inject class AssistedScoped(@Assisted val arg: Int)
  • Fixed edge case where accessing a parent scoped dependency from a lazy cycle generated invalid code.