InsertKoinIO / koin

Koin - a pragmatic lightweight dependency injection framework for Kotlin & Kotlin Multiplatform
https://insert-koin.io
Apache License 2.0
8.76k stars 695 forks source link

Koin module check fails when using injected parameters #1897

Open csanfilippo opened 5 days ago

csanfilippo commented 5 days ago

Describe the bug Koin module check fails when using injected parameters

To Reproduce Steps to reproduce the behavior:

  1. Create a simple KMP project
  2. Add koin as a dependency
  3. Write a test to check koin modules integrity. The module should inject parameters

Expected behavior Test passes

Koin module and version: koin-core:3.5.6

Snippet or Sample project to help reproduce

enum class TestEnum {
    VALUE1, VALUE2, VALUE3
}

class TestClass(val enum: TestEnum, val anInt: Int)

class KoinIntegrity : KoinTest {
    @Test
    fun checkKoinIntegrity() {
        val module = module {
            single<TestClass> { p ->
                TestClass(p.get(), get())
            }
            single<Int> { 11 }
        }

        checkKoinModules(listOf(module)) {
            withParameter<TestEnum> { TestEnum.VALUE2 }
        }
    }
}