How to use Result<T> in Kotlin Multiplatform project?

I want to use the Result class which is described here:

But when I try to use it as a return value of a function, I got 'kotlin.Result' cannot be used as a return type message.

In other Kotlin/JVM projects, I can easily add the below lines to build.gradle.kts and it works fine.

      tasks {
            withType<KotlinCompile> {
                kotlinOptions {
                    jvmTarget = JavaVersion.VERSION_1_8.toString()
                    freeCompilerArgs =
                        freeCompilerArgs + "-Xallow-result-return-type" + "-Xinline-classes"

Thank you.

you’ll need to do these inside of sourceSets in an all block. Simply you’ll have:

sourceSets {
    all {
        kotlinOptions {...}
// Rest of your sourcesets

It doesn’t work, cannot resolve kotlinOptions inside all {}