Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultiBindings @intoMap not working for (Map<K, V>) #1822

Closed
zoubarry opened this issue Apr 21, 2020 · 2 comments
Closed

MultiBindings @intoMap not working for (Map<K, V>) #1822

zoubarry opened this issue Apr 21, 2020 · 2 comments

Comments

@zoubarry
Copy link

zoubarry commented Apr 21, 2020

According to the doc here: https://dagger.dev/dev-guide/multibindings for @Intomap
Then you can inject either the map itself (Map<K, V>) or a map containing value providers (Map<K, Provider<V>>).

However, (Map<K, V>) is not working as expected with following setup:
Basically A1,A2 both implement A and I'm trying to inject both into factory constructor

@Binds @Prod @IntoMap @Key(A::class) fun prodA(prodA: A1): A

@Binds @Mock @IntoMap @Key(A::class) fun mockA(mockA: A2): A

class Factory @Inject constructor( @Mock private val mockMap: Map<Class<out A>, A>, @Prod private val prodMap: Map<Class<out A>, A> )

Error:
[Dagger/MissingBinding] @Mock Map<Class<out A>, A> cannot be provided without an @Provides-annotated method.

FYI Map<Class<out A>, Provider<A>> is working as expected though

@Chang-Eric
Copy link
Member

I think you might need @JvmSuppressWildcards See #900 (comment)

@zoubarry
Copy link
Author

thanks @Chang-Eric and that works for me 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants