amzn / kotlin-inject-anvil

Extensions for the kotlin-inject dependency injection framework
Apache License 2.0
240 stars 4 forks source link

Support scopes with parameters #1

Closed vRallev closed 1 month ago

vRallev commented 2 months ago

The code currently assumes that scope annotations have no parameters, e.g.

@Scope
annotation class SingleInAppScope

Since this ticket https://github.com/evant/kotlin-inject/issues/377 has been resolved, kotlin-inject supports parameters for scope annotations. The Anvil extensions should support scopes such as:

@Scope
annotation class SingleIn(val scope: KClass<*>)
ZacSweers commented 2 months ago

In my testing, this is working now in the latest kotlin-inject + KSP1. It's broken in KSP2 for now due to https://github.com/google/ksp/issues/2091