Hi, I’m trying to migrate from 3.2.2 to 3.3 in a m...
# koin
s
Hi, I’m trying to migrate from 3.2.2 to 3.3 in a multiplatform project. A number of
singleOf
declarations in the format below are now unable to be resolved at compile time. How should I be migrating these? I couldn’t seem to find any migration guide or detail of this in the changelog, unless I’ve missed something!
Copy code
module {
    // ...
	singleOf { a, b, c -> SomeFactory(a, b, c).build() }
}

// Compiler error:
// None of the following functions can be called with the arguments supplied: ...
// public inline fun <reified R> Module.singleOf(...
// etc ...
p
what error are you getting ?
s
Here’s more of the error, cut short to fit (and avoid repetition):
Copy code
None of the following functions can be called with the arguments supplied: 
public inline fun <reified R> Module.singleOf(crossinline constructor: () -> TypeVariable(R), noinline options: DefinitionOptions<TypeVariable(R)>? /* = (BeanDefinition<TypeVariable(R)>.() -> Unit)? */ = ...): KoinDefinition<TypeVariable(R)> defined in org.koin.core.module.dsl
public inline fun <reified R, reified T1> Module.singleOf(crossinline constructor: (TypeVariable(T1)) -> TypeVariable(R), noinline options: DefinitionOptions<TypeVariable(R)>? /* = (BeanDefinition<TypeVariable(R)>.() -> Unit)? */ = ...): KoinDefinition<TypeVariable(R)> defined in org.koin.core.module.dsl
public inline fun <reified R, reified T1, reified T2> Module.singleOf(crossinline constructor: (TypeVariable(T1), TypeVariable(T2)) -> TypeVariable(R), noinline options: DefinitionOptions<TypeVariable(R)>? /* = (BeanDefinition<TypeVariable(R)>.() -> Unit)? */ = ...): KoinDefinition<TypeVariable(R)> defined in org.koin.core.module.dsl
public inline fun <reified R, reified T1, reified T2, reified T3> Module.singleOf(crossinline constructor: (TypeVariable(T1), TypeVariable(T2), TypeVariable(T3)) -> TypeVariable(R), noinline options: DefinitionOptions<TypeVariable(R)>? /* = (BeanDefinition<TypeVariable(R)>.() -> Unit)? */ = ...): KoinDefinition<TypeVariable(R)> defined in org.koin.core.module.dsl
public inline fun <reified R, reified T1, reified T2, reified T3, reified T4> Module.singleOf(crossinline constructor: (TypeVariable(T1), TypeVariable(T2), TypeVariable(T3), TypeVariable(T4)) -> TypeVariable(R), noinline options: DefinitionOptions<TypeVariable(R)>? /* = (BeanDefinition<TypeVariable(R)>.() -> Unit)? */ = ...): KoinDefinition<TypeVariable(R)> defined in org.koin.core.module.dsl
public inline fun <reified R, reified T1, reified T2, reified T3, reified T4, reified T5> Module.singleOf(crossinline constructor: (TypeVariable(T1), TypeVariable(T2), TypeVariable(T3), TypeVariable(T4), TypeVariable(T5)) -> TypeVariable(R), noinline options: DefinitionOptions<TypeVariable(R)>? /* = (BeanDefinition<TypeVariable(R)>.() -> Unit)? */ = ...): KoinDefinition<TypeVariable(R)> defined in org.koin.core.module.dsl
public inline fun <reified R, reified T1, reified T2, reified T3, reified T4, reified T5, reified T6> Module.singleOf(crossinline constructor: (TypeVariable(T1), TypeVariable(T2), TypeVariable(T3), TypeVariable(T4), TypeVariable(T5), TypeVariable(T6)) -> TypeVariable(R), noinline options: DefinitionOptions<TypeVariable(R)>? /* = (BeanDefinition<TypeVariable(R)>.() -> Unit)? */ = ...): KoinDefinition<TypeVariable(R)> defined in org.koin.core.module.dsl
public inline fun <reified R, reified T1, reified T2, reified T3, reified T4, reified T5, reified T6, reified T7> Module.singleOf(crossinline constructor: (TypeVariable(T1), TypeVariable(T2), TypeVariable(T3), TypeVariable(T4), TypeVariable(T5), TypeVariable(T6), TypeVariable(T7)) -> TypeVariable(R), noinline options: DefinitionOptions<TypeVariable(R)>? /* = (BeanDefinition<TypeVariable(R)>.() -> Unit)? */ = ...): KoinDefinition<TypeVariable(R)> defined in org.koin.core.module.dsl
p
I don't have this problem it's strange did you try to only port one dependecy do singleOf and see the result ?
s
Not sure I follow, sorry! Quite a few of my existing dependencies are already
singleOf { … }
with zero errors in 3.2.2, I’m not sure what to port/migrate them to in order to fix the errors that appear when I use Koin 3.3
p
so if you revert version you don't get this ?
s
Exactly, yep – revert version to 3.2.2, no errors
p
but you can use DSL in 3.2.2 ?
is this an open source project or do you have an example where this is hapening where we can see it?
a
expression with Builder like
singleOf { a, b, c -> SomeFactory(a, b, c).build() }
won’t be replaceable with DSL Constructor
With constructor DSL we use directly a function/constructor to call
s
Thanks for the info Arnaud! Is there another way for me to use a builder like this with Koin, or should I migrate to the constructor-only approach now?
p
I think for build pattern you have to use old single ()
s
Finally made sense of things and solved the errors, thanks Pedro!