Skip to content

Destructuring of type 'org.koin.core.parameter.ParametersHolder' requires operator function 'component6()'. #2141

@HLCaptain

Description

@HLCaptain

Describe the bug

ViewModels (or other classes) with @KoinViewModel annotations and at least 6 @InjectedParam arguments end up with this build error:

Destructuring of type 'org.koin.core.parameter.ParametersHolder' requires operator function 'component6()'.

To Reproduce

  1. Have a class (in my case, Android ViewModel) with at least 6 @InjectedParam arguments.
  2. Build and run the project.
  3. The generated KoinDefault-*****.kt generates properly, but build throws the error: Destructuring of type 'org.koin.core.parameter.ParametersHolder' requires operator function 'component6()'.
// Class definition
@KoinViewModel
class CustomViewModel(
    @InjectedParam arg1: Boolean,
    @InjectedParam arg2: Boolean,
    @InjectedParam arg3: Boolean,
    @InjectedParam arg4: Boolean,
    @InjectedParam arg5: Boolean,
    @InjectedParam arg6: Boolean,
) : ViewModel() {
    // ...
}

// Generated fuction
@ExternalDefinition("com.my.app")
public fun Module.defineComMyAppCustomViewModel() : KoinDefinition<*> = viewModel() { (arg1 : kotlin : Boolean,arg2 : kotlin.Boolean,arg3 : kotlin.Boolean,arg4 : kotlin.Boolean,arg5 : kotlin.Boolean, arg6 : kotlin.Boolean) -> com.my.app.CustomViewModel(arg1,arg2,arg3,arg4,arg5,arg6) }

Expected behavior

Build does not throw error: there is a definition for 6+ component ParameterHolder.

Koin project used and used version (please complete the following information):

implementation(platform("io.insert-koin:koin-bom:4.0.2"))
implementation(platform("io.insert-koin:koin-annotations-bom:2.0.0"))
implementation("io.insert-koin:koin-android")
implementation("io.insert-koin:koin-android-compat")
implementation("io.insert-koin:koin-androidx-compose")
implementation("io.insert-koin:koin-androidx-compose-navigation")
implementation("io.insert-koin:koin-annotations")
ksp("io.insert-koin:koin-ksp-compiler:2.0.0")

Additional moduleDefinition

This bug is caused by Koin not accepting 6+ component ParameterHolder, but affects koin-annotation code generation as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    corestatus:checkingcurrently in analysis - discussion or need more detailed specs

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions