It seems to be related to SDKMan. If you’re using SDKMan, uninstall versions of Kotlin installed with SDKMan, and ensure all Gradle Daemons are stopped.
Try the build again, and it should work fine.
IntelliJ will use it’s own internal Kotlin compiler, OR delegate to Gradle build. Depends on your setting under build tools. You can use IntelliJ or delegate build to Gradle.
Another setting for tests.