Search code examples
kotlinkotlin-multiplatform

How to fix the `@JvmStatic` in interface usage error in IDEA when using Kotlin?


I have a Kotlin multiplatform project and the newest version of IDEA started to complain about @JvmStatic usages in interfaces:

enter image description here

What's weird is that I added the necessary config to my build.gradle.kts file:

kotlin {

    jvm {
        withJava()
        jvmTarget(JavaVersion.VERSION_1_8)
    }

    // ...
}

and I also set it up in IDEA here:

enter image description here

and here:

enter image description here

and I also added the compiler parameter as IDEA suggested. What am I doing wrong?

If I build the project from the command line I get a BUILD SUCCESSFUL.


Solution

  • This is a bug with multiplatform projects Gradle IDEA import: https://youtrack.jetbrains.com/issue/KT-43074. In this particular case it is acceptable to suppress the error until the bug is fixed:

    @Suppress("JVM_STATIC_IN_INTERFACE_1_6") // remove when KT-43074 is fixed
    fun empty() = ...