Let's say I have a class like below:

abstract class AbsTest { fun test(k: String, v: String? = null) { println("Key - $k, Value - $v") } }

And a class which inherits from it:

class Test : AbsTest { ... }

My main function looks something like this:

fun main() { Test().test("Hello") }

This works absolutely fine. However, if I do this in Kotlin Multi-platform, then it fails. Here is my KMP code:

expect abstract class AbsTest { fun test(k: String, v: String? = null) } // Android Target actual abstract class AbsTest { fun test(k: String, v: String?) { ... } } class Test : AbsTest { ... } // Calling Place fun finalTest() { Test().test("Hello") }

The above KMP code throws below exception:

java.lang.NoSuchMethodError: No static method test$default(...) in class AbsTest found

Out of curiosity, when I decompiled the code to check the generated bytecode, I found the problem that it doesn't generate the $default method for KMP project where as the other one works fine.

Decompiled code (normal Kotlin project)

public abstract class AbsTest { public final void test(@NotNull String k, @Nullable String v) { ... } public static void test$default(AbsTest var0, String var1, String var2, int var3, Object var4) { ... } }

Decompiled code (KMP project)

public abstract class AbsTest { public final void test(@NotNull String k, @Nullable String v) { ... } // No test$default() method generated }

Any reason why KMP behaves this way? How to fix this?