You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Registering two interfaces with the same name, but from different namespaces (e.g. TestClass1.SameName and TestClass2.SameName) always returns the last of the registered implementations. This only happens in Kotlin/Wasm.
To Reproduce
Run the sample snippet below and observe the console.
The console will show TestClass2SameNameImpl@... instead of TestClass1SameNameImpl@....
Expected behavior
Return an implementation of the requested interface, not the last one.
Koin module and version: koin-bom:4.0.0 with koin-core
Snippet or Sample project to help reproduce
packageorg.example.projectimportorg.koin.core.context.startKoinimportorg.koin.dsl.koinApplicationimportorg.koin.dsl.moduleclassTestClass1 {
interfaceSameName
}
classTestClass2 {
interfaceSameName
}
classTestClass1SameNameImpl : TestClass1.SameNameclassTestClass2SameNameImpl : TestClass2.SameNameval myModule = module {
single<TestClass1.SameName> { TestClass1SameNameImpl() }
single<TestClass2.SameName> { TestClass2SameNameImpl() }
}
funkoinConfiguration() = koinApplication {
modules(myModule)
}
funmain() {
val koin = startKoin(koinConfiguration())
val x = koin.koin.get<TestClass1.SameName>()
println(x) // Will print TestClass2SameNameImpl even though we requested TestClass1.SameName
}
The text was updated successfully, but these errors were encountered:
Describe the bug
Registering two interfaces with the same name, but from different namespaces (e.g.
TestClass1.SameName
andTestClass2.SameName
) always returns the last of the registered implementations. This only happens in Kotlin/Wasm.To Reproduce
Run the sample snippet below and observe the console.
The console will show
TestClass2SameNameImpl@...
instead ofTestClass1SameNameImpl@...
.Expected behavior
Return an implementation of the requested interface, not the last one.
Koin module and version:
koin-bom:4.0.0
withkoin-core
Snippet or Sample project to help reproduce
The text was updated successfully, but these errors were encountered: