koin-annotations
koin-annotations copied to clipboard
@InjectedParam with a nested generic type causes a compilation error
Describe the bug
Using an @InjectedParam with some type that has nested type arguments (e.g. List<List<Int>>) causes incorrect generation of a lambda factory in the containing module. Probably related to #240 and #272 . I guess it's directly caused by this line: https://github.com/InsertKoinIO/koin-annotations/blob/b0510067baa935687590e167be8f6e5c5d989a97/projects/koin-ksp-compiler/src/jvmMain/kotlin/org/koin/compiler/generator/DefinitionWriter.kt#L120
To Reproduce
Here's an MRE: https://github.com/Terenfear/koin-bug-reproducible-example. Just run :compileKotlinWasmJs or :compileAndroidMain.
Steps to reproduce the behavior:
- Create a class
@Single
class Foo(
@InjectedParam bar: List<List<String>>
)
- Add it to some module using
@ComponentScan - Try to compile the app.
Alternatively, instead of writing an annotated class declare a provider function with an injected parameter in a module. The behavior is the same.
Expected behavior No compilation error. The generated code looks something like this:
public val org_example_project_TestModule : Module get() = module {
single() { (bar : kotlin.collections.List<kotlin.collections.List<String>>) -> org.example.project.Foo(bar)}
}
Actual behavior A compilation error. It generates this code (notice a lack of the type argument of the second List):
public val org_example_project_TestModule : Module get() = module {
single() { (bar : kotlin.collections.List<kotlin.collections.List>) -> org.example.project.Foo(bar)}
}
Koin project used and used version (please complete the following information):
koin-core version 4.1.1koin-annotations version 2.3.0koin-ksp-compiler version 2.3.0