Is it expected that the constructor reference synt...
# koin
c
Is it expected that the constructor reference syntax for
singleOf
or
factoryOf
understands nullable dependencies?
Copy code
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 DSL
t
Just got the case, it crash at runtime when value is null. I guess that a easy to fall in.
Copy code
class 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()
    }