Egor
08/17/2021, 9:24 AM//========================== Script 1 =============================
@file:Import("script2.cp.kts")
fun doMain() {
doSomeDummyWork()
}
//========================== script2.cp.kts =============================
fun doSomeDummyWork(): Int {
return 42
}
The error message:
The root cause java.lang.RuntimeException was thrown at: org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:50)
at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException(CodegenUtil.kt:239)
at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException$default(CodegenUtil.kt:235)
...
Caused by: java.lang.RuntimeException: Exception while generating code for:
FUN name:doMain visibility:public modality:FINAL <> ($this:<root>.Script1_cp) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.Script1_cp
BLOCK_BODY
COMPOSITE type=kotlin.Unit origin=null
CALL 'public final fun doSomeDummyWork (): <http://kotlin.Int|kotlin.Int> declared in <root>.Script2_cp' type=<http://kotlin.Int|kotlin.Int> origin=null
$this: GET_VAR '<this>: <root>.Utils_cp declared in <root>.Rater_cp.<init>' type=<root>.Utils_cp origin=null
COMPOSITE type=kotlin.Unit origin=null
at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:50)
at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate$default(FunctionCodegen.kt:43)
...
Caused by: java.lang.IllegalStateException: No mapping for symbol: VALUE_PARAMETER SCRIPT_IMPLICIT_RECEIVER name:<this> index:1 type:<root>.Script2_cp
at org.jetbrains.kotlin.backend.jvm.codegen.IrFrameMap.typeOf(irCodegenUtils.kt:64)
at org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen.visitGetValue(ExpressionCodegen.kt:648)
@ilya.chernikov can you help here?Egor
08/17/2021, 9:28 AMuseOldBackend
option, but :
1. We do want to use new IR, from what I read it is going to improve things if not already
2. I'm afraid that in next releases, there will be some changes that will be not compatible with previous versions.Egor
08/17/2021, 9:33 AMval
s instead of fun
s the code will wotk. I mean something like that:
//========================== Script 1 =============================
@file:Import("script2.cp.kts")
val doMain: () -> Unit {
doSomeDummyWork()
}
//========================== script2.cp.kts =============================
fun doSomeDummyWork(): Int {
return 42
}
Please see that I changed doMain
to be val
here.
Another point is that it would work if I wrapped doSomeDummyWork()
in object
. (it make sense after all, but not really option for us as we can not use this objects for we sometimes use functions and fields defined in our abstract Script template the one with @KotlinScript
annotation)Egor
08/17/2021, 9:36 AMilya.chernikov
08/17/2021, 1:01 PMuseOldBackend
switch.Egor
08/17/2021, 9:54 PM