Describe the bug
I was debugging my issue with being unable to override a bean from other module for quite a long time and stumbled upon a core reason being that koin always overrides bean when the same module is included multiple times.
This issue is very hard to spot on a big project consisting of tens of modules!
To Reproduce
Steps to reproduce the behavior:
have a diamond configuration of modules, one of which does override
Depending on the end order of the modules your override of bean from leaf module can be overriden back to the original definition
Expected behavior
every module is processed and included exactly once
Koin module and version:koin-core:3.4.1
Snippet or Sample project to help reproduce
Consider this example:
val moduleA = module {
// bean A
}
val moduleB = module {
includes(moduleA) // depends on module a beans
// override bean A
}
val moduleC = module {
includes(moduleA) // depends on module a beans
}
val topLevelModule = module {
includes(moduleB, moduleC)
}
startKoin { modules(topLevelModule) }
In this example all modules observe original bean A from module A, because its override in moduleB is overwriten by moduleC including the module A. Changing order of include of modules moduleB and moduleC changes the outcome of resolution of bean A
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Describe the bug I was debugging my issue with being unable to override a bean from other module for quite a long time and stumbled upon a core reason being that koin always overrides bean when the same module is included multiple times. This issue is very hard to spot on a big project consisting of tens of modules!
To Reproduce Steps to reproduce the behavior:
Expected behavior every module is processed and included exactly once
Koin module and version:
koin-core:3.4.1
Snippet or Sample project to help reproduce Consider this example:
In this example all modules observe original bean A from module A, because its override in moduleB is overwriten by moduleC including the module A. Changing order of include of modules moduleB and moduleC changes the outcome of resolution of bean A