amzn / kotlin-inject-anvil

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

Support `@Component` annotations in a MergedComponent #83

Closed joshafeinberg closed 2 weeks ago

joshafeinberg commented 2 weeks ago

Issue #, if available: https://github.com/amzn/kotlin-inject-anvil/issues/76

Description of changes:

Checks if you have a component annotation and ensures that the annotation continues on, as well as marking it as a value and is an override.

@MergeComponent(AppScope::class)
@SingleIn(AppScope::class)
abstract class ComponentInterface(
    @Component val childComponent: ChildComponent,
)

generates

@Origin(value = ComponentInterface::class)
@Component
@MergeComponent(
  scope = AppScope::class,
  exclude = arrayOf(),
)
@SingleIn(scope = AppScope::class)
public abstract class KotlinInjectComponentInterface(
  @Component
  override val childComponentDelegate: ChildComponent,
) : ComponentInterface(childComponentDelegate),
    KotlinInjectComponentInterfaceMerged {
  public companion object
}