InsertKoinIO / InsertKoinIO/koin-compiler-plugin
[KOIN-D001] Missing dependency for parameters with Classic DSL
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 82
- Forks
- 15
- Avg merge
- 1m
- Merged PRs (30d)
- 1
Description
I am currently not able to use parameters with the Classic DSL and compile-time safety enabled.
This has been tested with Koin 4.2.2, Koin Compiler Plugin 1.0.2 (and 1.1.0) and Kotlin 2.4.10 in a native Android project.
// libs.versions.toml
[libraries]
koin-bom = { module = "io.insert-koin:koin-bom", version.ref = "4.2.2" }
koin-android = { module = "io.insert-koin:koin-android" }
koin-compose = { module = "io.insert-koin:koin-compose" }
koin-compose-viewmodel = { module = "io.insert-koin:koin-compose-viewmodel" }
[plugins]
koin-compiler = { id = "io.insert-koin.compiler.plugin", version.ref = "1.0.2" }
// .kt
fun sampleModule() = module {
factory<SampleUseCase>()
viewModel<SampleViewModel>()
}
SampleViewModel(
parameter: String,
useCase: SampleUseCase,
)
@Composable
fun Screen() {
val viewModel = koinViewModel<SampleViewModel>(key = id) { parametersOf(id) }
}
In this example useCase works but parameter fails.
e: [Koin][KOIN-D001] Missing dependency: kotlin.String
required by: dsl:SampleViewModel (parameter 'parameter')
in module: DSL graph
I did try annotating parameter with @InjectedParam (as stated here) but without success. Maybe I misread the documentation because shouldn't this work without using annotations?
Thanks in advance, have a nice day and all the best!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the sample with the Classic DSL, compile-time safety, and koinViewModel(...){ parametersOf(id)}; start by tracing compiler-plugin processing of the module's viewModel parameter and the @InjectedParam path. Done means the String parameter is supplied from parametersOf(id) without KOIN-D001 while useCase resolution remains valid, with regression coverage for this case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100