koin-annotations
koin-annotations copied to clipboard
The function Module.define<*> is overwritten in a multi-module project
trafficstars
Describe the bug A multi-module project run with an error when using classes with the same name.
To Reproduce Module 1
package testproject.test1
@Single
class Test{}
@Single
class Test1(val test: Test)
Module 2
package testproject.test2
@Single
class Test{}
@Single
class Test2(val test: Test)
Module Main
package testproject
@ComponentScan("testproject")
class AppModule
class MainActivity : AppCompatActivity() {
private val test1: Test1 by get()
private val test2: Test2 by get()
...
}
Result. Project run with error Caused by: org.koin.core.error.NoDefinitionFoundException: No definition found for type 'testproject.test2.Test'
This happens because the define<*> functions are added to the generated AppModule class without regard to the package name.
package org.koin.ksp.generated
AppModule = module {
defineTest()
defineTest1()
defineTest()
defineTest2()
}
Since there are two defineTest() functions, only the first one resolves.
Expected behavior Run the project without errors
Koin project used and used version: koin = "4.0.1-RC1" koin-annotations = "2.0.0-Beta2" or "1.4.0"