Hi! I’m encountering an issue with `@file:Import` ...
# scripting
s
Hi! I’m encountering an issue with
@file:Import
when running a script in the IDE. Getting this error when trying to add
@file:Import("script1.main.kts")
to
script2.main.kts
Copy code
error: backend Internal error: Exception during IR lowering
File being compiled: development/script1.main.kts
The root cause java.lang.RuntimeException was thrown at: org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:50) (script2.main.kts): org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering
File being compiled: development/script1.main.kts
The root cause java.lang.RuntimeException was thrown at: org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:50)
I saw this thread that suggested using
useOldBackend
until the bug is fixed, but I couldn’t figure out how to set this flag when running the script in the IDE. It also mentioned that the bug might be fixed in the kotlin 1.6 release, but I can’t find any documentation about how to specify the kotlin version for a
kotlin-main-kts
script 🤔 I wanted to try Kotlin 1.6.0-RC to see if the bug disappears, but I’m not sure how to define the script’s kotlin version. Thanks in advance!
b
You can't define script kotlin version as it's defined by kotinc used to invoke it. If you want to try out 1.6, download that binary and use it to invoke the script
s
hmm ok I’ll give that a shot, thanks! anyone have any guidance about how to configure
useOldBackend
?
n
i think its something like:
@file:CompilerOptions("-Xuse-old-backend")