InsertKoinIO / koin-annotations

Koin Annotations - About Koin - a pragmatic lightweight dependency injection framework for Kotlin & Kotlin Multiplatform insert-koin.io
https://insert-koin.io
Apache License 2.0
123 stars 30 forks source link

Wrong check of optional module when KOIN_CONFIG_CHECK is enabled #116

Open xinzhengzhang opened 4 months ago

xinzhengzhang commented 4 months ago

Describe the bug

The module for code generation is correct when the dependency is optional, but the KSP check will report an error.

To Reproduce

@Scope(MyScopeClass::class) @Scoped class MyScopeComponent(private val component2: MyScopeComponent2?)

class MyScopeComponent2

// Code gen public val kntr_base_log_MyModule : Module = module { single() { kntr.base.log.Factory() } bind(kntr.base.log.ILogger::class) scope { scoped() { kntr.base.log.MyScopeComponent(component2=getOrNull()) } } } public val kntr.base.log.MyModule.module : org.koin.core.module.Module get() = kntr_base_log_MyModule


* Enable `KOIN_CONFIG_CHECK`

error: [ksp] --> Missing Definition type 'kntr.base.log.MyScopeComponent2' for 'kntr.base.log.MyScopeComponent'. Fix your configuration to define type 'MyScopeComponent2'.



**Expected behavior**
Pass the configuration check correctly

**Koin project used and used version (please complete the following information):**
koin-annotation: 1.3.1
arnaudgiuliani commented 3 weeks ago

it's about a nullable dependency here then?