evant
01/11/2022, 3:06 PMtypealias Foo1 = Foo
typealias Foo2 = Foo
@Provides @IntoSet
fun foo1ForSet1(): Foo1 = ...
@Provides @IntoSet
fun foo2ForSet1(): Foo1 = ...
@Provides @IntoSet
fun foo1ForSet2(): Foo2 = ...
@Provides @IntoSet
fun foo2ForSet2(): Foo2 = ...
@Provides @IntoMap
fun fooSet1(set: Set<Foo1>): Pair<String, Set<Foo>> = "one" to set
@Provides @IntoMap
fun fooSet2(set: Set<Foo2>): Pair<String, Set<Foo>> = "two" to set
dave08
01/11/2022, 3:20 PMevant
01/11/2022, 3:46 PMdave08
01/11/2022, 3:49 PM@IntoMap @IntoSet
)... that's one of the problems with annotations, you can't assure the right combinations are being used and what the wrong ones might do...evant
01/11/2022, 3:54 PMevant
01/11/2022, 3:56 PMfun @Provides @IntoMap @IntoSet fun provideFoo(): Pair<String, Foo> = ...
abstract val fooMap: Map<String, Foo>
abstract val fooSet: Set<Pair<String, Foo>>
not sure if useful in practice...dave08
01/11/2022, 4:00 PMdave08
01/11/2022, 4:01 PMMap<String, Set<Foo>>
... not so pressing, but if easy to implement, would make that a bit more logical...dave08
01/11/2022, 4:13 PM@IntoSet
would probably throw... maybe an @IntoMapSet
would do both?
fun @Provides @IntoMap fun provideFoo1(): Pair<String, Foo> = "some-key" to Foo1()
fun @Provides @IntoMap fun provideFoo2(): Pair<String, Foo> = "some-key" to Foo2()
evant
01/11/2022, 4:15 PMmapOf(provideFoo1(), provideFoo2())
and the second key would override the first