compose-multiplatform icon indicating copy to clipboard operation
compose-multiplatform copied to clipboard

IrLinkageError: Constructor can not be called: The call site provides less value arguments than the constructor requires

Open jbruchanov opened this issue 2 years ago • 3 comments

iOS app crashing due to

Uncaught Kotlin exception: kotlin.native.internal.IrLinkageError: Constructor 'KQualifiers.' can not be called: The call site provides less value arguments (1) than the constructor requires (2)

Affected platforms Select one of the platforms below:

  • iOS

Versions

  • Kotlin version*: 1.9.0, 1.9.10
  • Compose Multiplatform version*: 1.5.0, 1.5.1
  • OS version(s)* (required for Desktop and iOS issues): Iphone 14 , iOS 16.4 (simulator)

To Reproduce

  • clone https://github.com/jbruchanov/kostra.git & switch to IrLinkageError branch
  • in kostra/sample run ./gradlew shared:generateCode shared:generateDatabases
  • open kostra/sample in Android studio (be sure about sample subfolder as root), AS probably needs some plugin to be able to start ios App
  • select appIos in run configurations and start it...

=> app crashing with kotlin.native.internal.IrLinkageError exception. The problematic line is this https://github.com/jbruchanov/kostra/blob/IrLinkageError/sample/shared/src/iosMain/kotlin/Main.ios.kt#L22

Expected behavior App doesn't crash

Additional context The problem seems to be coming from a combination of composable/extension function/value class/default argument + probably something else, I wasn't able to create tiny code example to reproduce it.

//crashing
//Text(Resources.assetPath(K.drawable.capital_city))
//this one is OK
Text(Resources.assetPath(K.drawable.capital_city, LocalQualifiers.current))

Updating the assetPath() to have simply overloaded function with no default values helps as workaround

Stacktrace

Uncaught Kotlin exception: kotlin.native.internal.IrLinkageError: Constructor 'KQualifiers.<init>' can not be called: The call site provides less value arguments (1) than the constructor requires (2)
    at 0   appIos                              0x10d5aa1cb        kfun:kotlin.Throwable#<init>(kotlin.String?){} + 107 
    at 1   appIos                              0x10d5a4a17        kfun:kotlin.Error#<init>(kotlin.String?){} + 103 
    at 2   appIos                              0x10d5e7697        kfun:kotlin.native.internal.IrLinkageError#<init>(kotlin.String?){} + 103 
    at 3   appIos                              0x10d5e7622        kfun:kotlin.native.internal#ThrowIrLinkageError(kotlin.String?){}kotlin.Nothing + 178 
    at 4   appIos                              0x10dd402ca        kfun:ComposableSingletons$Main_iosKt.<init>$lambda$0#internal + 7034 
    at 5   appIos                              0x10dd40fd1        kfun:ComposableSingletons$Main_iosKt.$<init>$lambda$0$FUNCTION_REFERENCE$0.invoke#internal + 97 
    at 6   appIos                              0x10dd4108d        kfun:ComposableSingletons$Main_iosKt.$<init>$lambda$0$FUNCTION_REFERENCE$0.$<bridge-UNNNB>invoke(androidx.compose.runtime.Composer;kotlin.Int){}#internal + 173 
    at 7   appIos                              0x10d8a5952        kfun:androidx.compose.runtime.internal.ComposableLambdaImpl#invoke(androidx.compose.runtime.Composer;kotlin.Int){}kotlin.Any? + 1106 
    at 8   appIos                              0x10d8bbaa1        kfun:androidx.compose.runtime.internal.ComposableLambdaImpl#$<bridge-NNNNB>invoke(androidx.compose.runtime.Composer;kotlin.Int){}kotlin.Any?(androidx.compose.runtime.Composer;kotlin.Any?){}kotlin.Any? + 177 
    at 9   appIos                              0x10dd33922        kfun:androidx.compose.material.Surface$lambda$2#internal + 8674 
...

jbruchanov avatar Sep 07 '23 22:09 jbruchanov

Thanks!

Reproduced here as well: We should have this in one module:

import kotlin.jvm.JvmInline

@JvmInline
value class Test(val key: Int) {
    constructor(a: String, b: String) : this(0)
}

And this in another module:

import androidx.compose.runtime.Composable

@Composable
fun App() {
    test()
}

@Composable
fun test(qualifiers: Test = Test(0)): String = "test"

Isn't reproducible on Android/desktop, reproducible on iOS.

igordmn avatar Sep 12 '23 23:09 igordmn

retested and still reproducible with

Kotlin version*: "1.9.20" Compose Multiplatform version*: 1.5.10

jbruchanov avatar Nov 03 '23 17:11 jbruchanov

any update on this?

gkiss01 avatar Nov 25 '23 16:11 gkiss01