Home > Enterprise >  What is the default Kotlin language version per Kotlin release?
What is the default Kotlin language version per Kotlin release?

Time:09-30

While looking at the "What's new" of Kotlin 1.7.20, I see that I need to set the Kotlin language version to 1.8 if I want to use the latest features.

So far, I have never set the language version. What is the default value of Kotlin language version per Kotlin release? And where is it documented?

CodePudding user response:

The language version is the release version.

For your specific example, the documentation queries 1.8 because it is an experimental feature. It means that the current release (1.7.20) does not ship/accept this feature for stable builds.

Therefore, you have to ask the compiler to activate features planned for the next Kotlin release, i.e 1.8.

Compiler -language-version option can serve to activate experimental features, but also in the other way: to prevent using features introduced after a specific version.

Now, why provide such option, and not "just" change compiler binary to match the wanted version ?

I am not sure, but I think that it allows a project to keep maintaining a certain version compatibility (which can be important for the community), and still benefit from bugfixes and performance improvements of newly released compilers.

But, the main point is that for now, compiler and language versions of Kotlin are aligned.

EDIT : I have not found much information about that, but it looks like the language-version option is really designed for experimental feature, not much for backward language compatibility. In the follwing Youtrack issue, they mention that the compiler should raise a warning if language-version is set to an old language version.

  • Related