https://kotlinlang.org logo
#dagger
Title
# dagger
j

jw

09/24/2019, 2:57 PM
Hey all. We're starting to land some Kotlin-specific changes into Dagger! Two have already landed which will be in the next release: - Understand qualifier annotations on properties without requiring a use-site target (i.e.,
@Whatever
instead of
@field:Whatever
) - Understand
@Module
on
object
does not require a module instance. We have a few more in the pipeline, but if you have any ideas of small ergonomic improvements like this please file an issue on GitHub.
👽 2
👍 9
❤️ 4
🎉 34
z

zachtib

09/24/2019, 2:59 PM
Is there any chance of ever getting to
@Inject
annotate the class declaration in order to specify the default constructor rather than having to break the constructor out?
👌 1
j

jw

09/24/2019, 3:08 PM
The
@Inject
annotation does not allow targeting to types. You'd probably have better luck getting Kotlin to add an annotation use-site target for the primary constructor for class-level annotations.
1
z

zachtib

09/24/2019, 3:09 PM
gotcha, would that be something to post on their YouTrack?
j

jw

09/24/2019, 3:11 PM
Yes
z

zachtib

09/24/2019, 3:11 PM
Thanks. Happy to see some Kotlin QoL improvements in Dagger, though!
a

arekolek

09/24/2019, 3:12 PM
So the second one is about static provides?
j

jw

09/24/2019, 3:14 PM
Yes. Providers on an object will be interpreted as "static" without needing
@JvmStatic
.
🎉 10
👍 4
👌 6
The generated code now knows to call
Whatever.INSTANCE.method()
in that case.
And then R8 has a staticization pass which will likely eliminate the
INSTANCE
altogether and make them static in bytecode anyway. More details on that at https://jakewharton.com/r8-optimization-staticization/
🔥 3
g

gildor

09/25/2019, 2:02 AM
The need for
@JvmSuppressWildcards
is significantly decrease ergomonics, especially for lambdas
👍 1
j

jw

09/25/2019, 2:04 AM
That's next on my list. Well, first. The listed two things were done by someone else.
👍 5
g

gildor

09/25/2019, 2:15 AM
typealias as qualifier, but it, I believe, already was reported
j

jw

09/25/2019, 2:16 AM
Yeah I'm not sure I quite buy that one
g

gildor

09/25/2019, 2:18 AM
Yeah, also not sure about backward compatibility with existing code, but looks still nice to have super simple way to declare qualifiers. But anyway, looks that we use
@Named
much more than annotation because of multi-module project
p

Paul Woitaschek

09/26/2019, 10:14 AM
Rename component and module into something less ambiguous 😉