Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two interfaces with the same name always return the latter one in Kotlin/Wasm #2030

Open
fhilgers opened this issue Oct 16, 2024 · 2 comments
Milestone

Comments

@fhilgers
Copy link

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

package org.example.project

import org.koin.core.context.startKoin
import org.koin.dsl.koinApplication
import org.koin.dsl.module

class TestClass1 {
    interface SameName
}

class TestClass2 {
    interface SameName
}

class TestClass1SameNameImpl : TestClass1.SameName
class TestClass2SameNameImpl : TestClass2.SameName

val myModule = module {
    single<TestClass1.SameName> { TestClass1SameNameImpl() }
    single<TestClass2.SameName> { TestClass2SameNameImpl() }
}

fun koinConfiguration() = koinApplication {
    modules(myModule)
}

fun main() {
    val koin = startKoin(koinConfiguration())
    val x = koin.koin.get<TestClass1.SameName>()
    println(x) // Will print TestClass2SameNameImpl even though we requested TestClass1.SameName
}
@arnaudgiuliani arnaudgiuliani added this to the 4.0.1 milestone Nov 15, 2024
@arnaudgiuliani
Copy link
Member

super weird O.o

@edouardouvrard
Copy link

Same problem on iOS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants