java - Kotlin+Dagger2 @Named annotation in Module provider method usage -




i’m having problem using dagger 2 @named annotation in kotlin preventing me migrating dagger graph kotlin. problem occurs when need inject in dagger module method @named parameter. in case i’m not injecting through constructor or field. i’ve tried kotlin annotation use-sites targets , none of them seems work in method parameter. please, solution appreciated. below portion of java code once converted kotlin won't compile:

@module public final class mymodule {     (...)     @provides    @singleton    loginstore provideloginstore(@named("main_dao_session") daosession maindaosession, @named("demo_dao_session") daosession demodaosession) {       return new loginstoreimpl(maindaosession, demodaosession);    }     (...)  } 

use-site targets not apply in case, since you're dealing function parameters. target needs specified constructors because lot of code generated in background each constructor parameters.

just use annotation would:

@provides @singleton fun provideloginstore(@named("main_dao_session") maindaosession: daosession, @named("demo_dao_session") demodaosession: daosession): loginstore {     return loginstoreimpl(maindaosession, demodaosession) } 




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -