Kotlin equivalent of javac --release

Since JDK 9 it has been possible to specify the target version of the JVM with the --release argument on javac.

When this argument is provided the compiler checks that your code does not use any APIs that were added to the JDK after the targetted release. So specifying --release 8 and calling a method added in JDK 9 will cause a compilation error.

Is there an equivalent argument for kotlinc?

We have a multi-module project that is a mixture of Kotlin and Java and has some modules that are compiled for Java 8 and some for Java 11. Recently someone updated some Kotlin code in a Java 8 module to use a method added to the JDK in v10. The build succeeded and the code only blew up at runtime.

This wouldn’t have happened if they had made the same mistake in Java because the release was set to 8 and the build would have failed.

The problem is made worse because IntelliJ doesn’t spot the error either, although it does spot the equivalent problem in Java code.

Cheers,
Chris

This is not implemented for Kotlin yet, please vote/follow https://youtrack.jetbrains.com/issue/KT-29974.