Getting an error between a Provider written in jav...
# dagger
c
Getting an error between a Provider written in java, and an @inject written in Kotlin. I need to do field injection, and so I have
@Inject var taxes: Taxes? = null
Unfortunately it needs to be nullable as the provider is nullable, but I get an error saying Dagger does not support injection into private fields... which leads me to do
@set:Inject var taxes: Taxes? = null
and everything works. I could have sworn that this "workaround" wasn't needed for latest versions of dagger. Am I missing something?
t
I'd prob recommend you wrap it in an
Optional
type. The set qualifier seems brittle to me, because the type of the synthetic set is going to be nullable still and dagger is probably just not checking function injects for nullability. which should probably be considered a bug being that it is inconsistent with the field injection behavior. That said a manually written set function wrapped around a nullable private var could also work, I just think the Optional type wrapper more explicitly spells out the intent here. IMO nullable typed var != optional element because the semantics of why can vary wildly
👍 1