daugeldauge/kinzhal

Support scope validation

Opened this issue · 0 comments

It's possible to create component which provides dependencies with wrong scopes, because there are no such checks here:

https://github.com/daugeldauge/kinzhal/blob/master/kinzhal-processor/src/jvmMain/kotlin/com/daugeldauge/kinzhal/processor/KinzhalSymbolProcessor.kt#L12

https://github.com/daugeldauge/kinzhal/blob/64f84c2dd0c251a89f3c66703858e5b627dddf9d/kinzhal-processor/src/jvmMain/kotlin/com/daugeldauge/kinzhal/processor/generation/FactoryGenerator.kt#L29C4-L29C4

Example:

// Unscoped component, or component with some another scope
interface Component(modules = [FooModule::class]) {
    ...
}

object FooModule {
    @Foo // Some scope here
    fun provideFoo() : Foo{
        ...
    }
}

This compiles fine and scope will work for Foo, however it's confusing because this scope is not attached to the current component