curioustechizen
04/02/2026, 10:36 AMsingleOf or factoryOf understands nullable dependencies?
class Foo(val bar: Bar?)
val myModule = module { singleOf(::Foo) }
Should koin be able to use getOrNull() instead of get() for the bar dependency? I'm not using annotations or compiler plugin - just classic DSLtezov
04/05/2026, 6:37 AMclass Nested
class Single(
val nested: Nested?
)
@Test
fun `singleOf with nullable constructor argument`() {
val koinApplication = koinApplication {
modules(module {
// singleOf(::Nested)
singleOf(::Single)
})
}
// Comment this line, no issue
// Uncomment, crash at runtime
val first = koinApplication.koin.getSingle()
}