https://kotlinlang.org logo
#koin-contributors
Title
# koin-contributors
p

Pedro Francisco de Sousa Neto

02/27/2024, 8:35 PM
I know, what I'll ask is weird, but there is some way to avoid Koin compile safety fails in compile time because of non-annotated dependencies? I'm bypassing like this:
Copy code
@Module
@ComponentScan("<http://br.com.custom.secret.app|br.com.custom.secret.app>")
class MyModule {

    @Factory
    fun getNonKoinAnnotatedAppLog(): AppLog {
        return GlobalContext.get().get<AppLog>()
    }

    @Factory
    fun getNonKoinAnnotatedGson(): Gson {
        return GlobalContext.get().get<Gson>()
    }

}
u

undermark5

02/27/2024, 11:48 PM
In all likelihood probably not, simply because during compile time, you'd have to find all of the non-annotated modules, verify if they have the definition you need as well of all it's required dependencies, which is going to be pretty tricky to do with KSP. Perhaps it can be done, but probably wasn't worth the level of effort for an initial implementation (plus it's still described as experimental in the documentation)
a

arnaud.giuliani

02/28/2024, 7:53 AM
you should use function parameter for your dependencies here, else it's "dynamic" resolution that can't be checked statically
👍 1
p

Pedro Francisco de Sousa Neto

02/28/2024, 12:52 PM
Yeah... so I think this is the pretties hack at moment.
😄 1