InsertKoinIO / koin-annotations

Koin Annotations - About Koin - a pragmatic lightweight dependency injection framework for Kotlin & Kotlin Multiplatform insert-koin.io
https://insert-koin.io
Apache License 2.0
154 stars 40 forks source link

@ComponentScan typealias annotation not working. #97

Closed taetae98coding closed 2 months ago

taetae98coding commented 11 months ago

Describe the bug I use Hilt for Android and Koin for nonAndroid in same repository. And use typealias nonAndroidTarget,

// KFactory.kt in commonMain
public expect annotation class KFactory

// KFactory.nonAndroid.kt
public actual typealias KFactory = Factory

// KFactory.android.kt
public actual annotation class KFactory
// MemoUpsertUseCase.kt in commonMain
@KFactory
public class MemoUpsertUseCase @KInject internal constructor(
    private val memoRepository: MemoRepository,
) : UseCase<Memo, Unit>() {
    override suspend fun execute(params: Memo) {
        if (params.title.isEmpty()) throw TitleEmptyException()

        memoRepository.upsert(params)
    }
}
// UseCaseModule in commonMain
@Module
@ComponentScan
public class UseCaseModule

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior I expected generated code like this.

public val com_taetae98_codelab_domain_usecase_UseCaseModule : Module = module {
    factory() { com.taetae98.codelab.domain.usecase.memo.MemoUpsertUseCase(memoRepository=get()) } bind(com.taetae98.codelab.domain.usecase.core.UseCase::class)
}
public val com.taetae98.codelab.domain.usecase.UseCaseModule.module : org.koin.core.module.Module get() = com_taetae98_codelab_domain_usecase_UseCaseModule

But generated code is this.

public val com_taetae98_codelab_domain_usecase_UseCaseModule : Module = module {
}
public val com.taetae98.codelab.domain.usecase.UseCaseModule.module : org.koin.core.module.Module get() = com_taetae98_codelab_domain_usecase_UseCaseModule

Koin project used and used version (please complete the following information): koin-bom : 3.5.1 koin-annotations-bom : 1.3.0

Additional moduleDefinition Add any other moduleDefinition about the problem here.

arnaudgiuliani commented 8 months ago

For now type aliases are not recognized. This is something that the compiler would try to detect aliases annotations. Why do you need to alias existing annotations?

stale[bot] commented 3 months ago

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.