Dagger 2 multibindings with Kotlin

前端 未结 1 1943
礼貌的吻别
礼貌的吻别 2020-12-09 07:20

I have the following snippet in my dagger 2 module

@Singleton
@Provides
@ElementsIntoSet
fun providesQueries(foo: Foo): Set{
    val queries = Lin         


        
1条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-09 08:20

    As it described in the Kotlin reference

    To make Kotlin APIs work in Java we generate Box as Box for covariantly defined Box (or Foo for contravariantly defined Foo) when it appears as a parameter.

    You can use @JvmSuppressWildcards for avoiding it, just as following:

    @Inject lateinit var foo: Set<@JvmSuppressWildcards Foo>
    

    0 讨论(0)
提交回复
热议问题