koin-annotations icon indicating copy to clipboard operation
koin-annotations copied to clipboard

Code Generation Issue in 'Conflict overloads'

Open DroidLin opened this issue 4 months ago • 1 comments

Describe the bug i got an compilation error in task: `compileDebugKotlinAndroid', which costs a mount of time to find out the way to solve.

i still cannot find the stable reproducible code except in my private project. but i`ve find something to make the compilation success and the way that will fail the compilation.

my local dependency version is:

agp = "8.10.0"

kotlin = "2.2.0"

# ksp
ksp = "2.2.0-2.0.2"

# koin
koin = "4.1.0"
koin-annotation = "2.1.0"

To Reproduce(maybe help)

@Module
@ComponentScan
class AppNetworkModule

interface CookieService {
    // ...
}

@Singleton(binds = [CookieService::class, CookieServiceImpl::class])
internal class CookieServiceImpl : CookieService {
    // ...
}

when i add CookieServiceImpl::class in @Singleton#binds parameter, it will fail with an error:

e: file:///Users/liuzhongao/IdeaProjects/EchoLink/client-feature/foundation/network/build/generated/ksp/metadata/commonMain/kotlin/org/koin/ksp/generated/KoinMeta-0a2f2ecd.kt:16:14 Conflicting overloads:
fun _KSP_OrgEcholinkNetworkRepositoriesCookieServiceImpl(): Unit

the magic is, when i remove one param CookieServiceImpl::class, then the declaration is like follow, it compiles successfully:

@Singleton(binds = [CookieService::class])
internal class CookieServiceImpl : CookieService {
    // ...
}

i`ve been carefully reviewed your compiler code, the only issue that may cause the problem exists in this two places: 1. Image

Image

by reading your code, i find out this is the way to prevent from re-generate the same Koin-Definition in both commonMain and sub-Main(like androidMain,iosMain etc). but in my case it has conflict, maybe you can find out why it happens, or change a new way to solve the issues that re-generate the same code.

DroidLin avatar Jul 19 '25 19:07 DroidLin

Currently branch 2.2.0 is bumped to "2.1.21-2.0.2", https://github.com/InsertKoinIO/koin-annotations/tree/2.2.0

Could you check with such version?

arnaudgiuliani avatar Jul 22 '25 14:07 arnaudgiuliani