Kotlin compiler embeded and Intellij platform don't work together?

I’m developing a platform plugin and I am including ktfmt jar (v0.54). I also think ktfmt uses org.jetbrains.kotlin:kotlin-compiler-embeddable which I believe is causing this issue. Anyway I put together a small example, which compiles and runs just fine, until I try to include ktfmt. I get the following errors.

Argument type mismatch: actual type is ‘KotlinFileType!’, but ‘LanguageFileType’ was expected.
Argument type mismatch: actual type is ‘KotlinLanguage’, but ‘Language’ was expected.

Of course KotlinFileType is a LanguageFileType, and KotlinLanguage is a Language according to their class declarations. I would like to get suggestions on how to overcome this conflict. Do I need to somehow use ktfmt is an isolated manner? Recompile ktfmt differently?
Regards,
Ralph Williamson

main.kt

import com.facebook.ktfmt.format.Formatter
import com.intellij.lang.Language
import com.intellij.openapi.editor.EditorFactory
import com.intellij.openapi.editor.ex.EditorEx
import com.intellij.openapi.fileTypes.FileTypeEditorHighlighterProviders
import com.intellij.openapi.fileTypes.LanguageFileType
import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.idea.KotlinLanguage

fun main()
{
    println("Hello, ${myfunction(language = KotlinLanguage.INSTANCE,
                                 fileType = KotlinFileType.INSTANCE)}!");
}

fun myfunction(language: Language,
               fileType: LanguageFileType): String
{
// This is in my plugin, not the example. This is why I need fileType...
//    val editor = EditorFactory.getInstance().createEditor(EditorFactory.getInstance().createDocument(CODE)) as EditorEx;
//    FileTypeEditorHighlighterProviders.getInstance().forFileType(fileType)
//        .getEditorHighlighter(null,
//                              fileType,
//                              null,
//                              editor.colorsScheme);

    val formattingOptions = Formatter.KOTLINLANG_FORMAT;
    val formattedContent = Formatter.format(formattingOptions, CODE)

    return "${language.id}: $formattedContent";
}

val CODE: String =
    """
        open class Some
    """

build.gradle.kts

plugins {
    id("java")
    kotlin("jvm") version "2.1.21"
    id("org.jetbrains.intellij.platform") version "2.6.0"
}

group = "net.ddns.rkdawenterprises"
version = "1.0-SNAPSHOT"

repositories {
    mavenCentral()

    intellijPlatform {
        defaultRepositories()
    }
}

dependencies {
    implementation("com.facebook:ktfmt:0.54")
    
    intellijPlatform {
        create(providers.gradleProperty("platformType"), providers.gradleProperty("platformVersion"))
    }
}

kotlin {
    jvmToolchain(21)
}

tasks.withType<Jar> {
    manifest {
        attributes["Main-Class"] = "net.ddns.rkdawenterprises.example.MainKt";
    }
}

So I ended up recompiling ktfmt core with kotlin compiler (org.jetbrains.kotlin:kotlin-compiler) rather than kotlin compiler embedded (org.jetbrains.kotlin:kotlin-compiler-embeddable) with required changes. And the conflict goes away. Although I would rather not maintain my own version of ktfmt, I guess this will be my solution.