elect
elect

Reputation: 7190

How to try inline classes in Kotlin

It looks like inline classes are available in Kotlin since 1.2.30

According to Wasabi375, you can enable them by:

compileKotlin {
    kotlinOptions {
        freeCompilerArgs += ['-XXLanguage:+InlineClasses']
    }
}

I did that in one project we have, but I keep getting tons of

Class 'unsigned.ByteKt' is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler

I tried to clean & build, upgrade Gradle to 4.9, using allprojects { }, but nothing worked..

This is the complete log

How can I solve it?

Ps: note that those unsigned classes have nothing to do with the experimental unsigned from Kotlin 1.3

Upvotes: 4

Views: 1119

Answers (1)

hotkey
hotkey

Reputation: 147981

Using experimental language features like inline classes leads to the produced binaries being marked with a special pre-release flag, which renders the binaries unusable with release versions of the compiler.

In order to bypass the pre-release status check on the binaries, you can compile their usages with the flag -Xskip-metadata-version-check.

However, you are advised not to do so and not to use binaries compiled with unannounced pre-release language features in production, as later versions of the compiler may behave differently regarding these features.

Upvotes: 5

Related Questions