Hi there! So… I've nudged my team to try out KMP f...
# multiplatform
a
Hi there! So… I've nudged my team to try out KMP for a new project. It's great and the mobile devs are very happy. However, it is not allowed in my organization to write a single line of Kotlin code in the backend. This means, we trigger this bug in the K2 plugin all the time: https://youtrack.jetbrains.com/issue/KTIJ-28429/K2-IDE-false-positive-Type-parameter-is-[…]r-java.lang.Enum-with-Kotlin-enum-from-common-source-root This in practice results in dozens of type errors in the IDE, e.g. we cannot use a Java String for a Kotlin function which takes a Kotlin String, same for Lists. Here is an example:
Copy code
@JvmStatic
fun exampleFunction(
    foo: String,
    bar: List<String>,
): List<String> = bar.map { "$foo-$it" }
Called in Java:
Copy code
List<String> foo = List.of("foo", "bar");
    DebugKt.exampleFunction("baz", foo);
Results in the following IDE Errors:
Copy code
'exampleFunction(java.lang.@org.jetbrains.annotations.NotNull String, java.util.@org.jetbrains.annotations.NotNull List<java.lang.@org.jetbrains.annotations.NotNull String>)' in 'com.example.DebugKt' cannot be applied to '(java.lang.String, java.util.List<java.lang.String>)'
Any idea on how to work around this issue? All the issues I've found look pretty stale. Our current workaround is to disable the K2 plugin whenever we work in the backend because the legacy plugin doesn't have this bug.