Paul Woitaschek
06/16/2020, 8:38 AM#!/usr/bin/env kotlin
@file:CompilerOptions("-Xopt-in=kotlin.time.ExperimentalTime","-jvm-target=1.8")
@file:DependsOn("com.github.ajalt:clikt:2.7.1")
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.options.required
import com.github.ajalt.clikt.parameters.types.enum
enum class RPS {
Rock
}
class Application : CliktCommand(){
private val rps : RPS by option("--rps").enum<RPS>().required()
override fun run() {
println(rps)
}
}
Application().main(args)
This doesn't compile:
➜ scripts git:(features/huawei_health) ✗ ./test.main.kts -- --rps rock
error: cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option (test.main.kts:16:44)
test.main.kts:16:44: error: cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
private val rps : RPS by option("--rps").enum<RPS>().required()
ilya.chernikov
06/17/2020, 10:40 AM=
. So, your annotation should look like
@file:CompilerOptions("-Xopt-in=kotlin.time.ExperimentalTime","-jvm-target", "1.8")
it works for me after this change.
Proper diagnostic is definitely missing here. I'd appreciate very much if you'll file an issue in YouTrack about it.