kosi-libs / Kodein

Painless Kotlin Dependency Injection

Home Page:https://kosi-libs.org/kodein

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using copy method on Module instances, returns Module instances that eventually fail with "module must have a name"

caeus opened this issue · comments

commented

Basically, since I upgraded to Kodein 7.14.0, I'm getting that error.

I have an app builder that receives a module that I'd want to be able to override previous bindings.

So I register a copy of that module that has allowSilentOverride = true using the copy method.
Once I instantiate the DI Container, BOOM! I get that error.

So I'm wondering... why not leaving the name as part of the main constructor of a module?, and if that's not possible, we could make the module not a data class but a simple one.

commented
        DI.Module("MyModule") {}.copy(allowSilentOverride = true).name

To override a module you should use import
https://kosi-libs.org/kodein/7.14.0/core/modules-inheritance.html#_overriding

The name is not defined as part of the data class to provide the ability to use delegation like by DI.Module {}