anvil
anvil copied to clipboard
Feature Request: Identify identical members from contributed components and override them
Consider this example
@MergeComponent(StartupScope::class)
@SingleIn(StartupScope::class)
interface StartupComponent {
val okHttpClient: OkHttpClient
}
// Elsewhere
@ContributesTo(StartupScope::class)
interface ThingDependencies {
val okHttpClient: OkHttpClient
}
Currently, this would fail to compile at component merging due to a missing override of okHttpClient. It would be ideal if anvil could identify these and add them as needed.
Note that qualifiers are considered part of the type, so @ForScope(AppScope::class) OkHttpClient and OkHttpClient would be different types and need to be deemed an error.
Another edge case besides different qualifiers is that names could clash for different types. Functions need to be considered as well, e.g.
@MergeComponent(StartupScope::class)
@SingleIn(StartupScope::class)
interface StartupComponent {
fun client(): OkHttpClient
}
// Elsewhere
@ContributesTo(StartupScope::class)
interface ThingDependencies {
fun client(): AwsClient
}
(inheritance should be supported)