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

flatten modules order error #1998

Open
luozejiaqun opened this issue Sep 24, 2024 · 3 comments · May be fixed by #1999
Open

flatten modules order error #1998

luozejiaqun opened this issue Sep 24, 2024 · 3 comments · May be fixed by #1999
Labels
question Usage question

Comments

@luozejiaqun
Copy link

Describe the bug
The order of modules after flattened is wrong.

Koin module and version:
koin-core:4.0.0

Snippet:

    interface ComponentInterface1
    class Component1 : ComponentInterface1
    class Component2 : ComponentInterface1

    val m1 = module {
        single<Simple.ComponentInterface1> { Simple.Component1() }
    }
    val m2 = module {
        single<Simple.ComponentInterface1> { Simple.Component2() }
    }
    val m3 = module { includes(m1, m2) }
    val app = koinApplication {
        modules(m3)
    }

    val koin = app.koin
    val component = koin.get<Simple.ComponentInterface1>()
    assertTrue { component is Simple.Component2 } // this fails

Expected behavior
This is because when m3 gets flattened, we get modules in order m3, m2, m1, the expected order is m3, m1, m2.

luozejiaqun added a commit to luozejiaqun/koin that referenced this issue Sep 24, 2024
@luozejiaqun luozejiaqun linked a pull request Sep 24, 2024 that will close this issue
luozejiaqun added a commit to luozejiaqun/koin that referenced this issue Sep 24, 2024
luozejiaqun added a commit to luozejiaqun/koin that referenced this issue Oct 23, 2024
luozejiaqun added a commit to luozejiaqun/koin that referenced this issue Oct 23, 2024
@arnaudgiuliani
Copy link
Member

any regression over 3.5?

@arnaudgiuliani arnaudgiuliani added the question Usage question label Nov 15, 2024
@luozejiaqun
Copy link
Author

@arnaudgiuliani 3.5 works fine. The module flattening refactor in 4.0 introduced this issue.

@arnaudgiuliani
Copy link
Member

for sure, it has been reworked in 3.6 Beta to fix memory allocation. Let me double check

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

Successfully merging a pull request may close this issue.

2 participants