Jonas TM
09/17/2022, 10:28 AMJonas TM
09/17/2022, 10:28 AM1.7.10
I added the feature flag to my build.gradle.kts
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs = listOf("-Xcontext-receivers")
}
}
But when I run the program via :runDebugExecutable
I get the following error while compiling:
The feature "context receivers" is experimental and should be enabled explicitly
Sebastian Sellmair [JB]
09/17/2022, 2:02 PMJonas TM
09/17/2022, 2:04 PMKotlinNativeCompile
class helped get rid of that error.Sebastian Sellmair [JB]
09/17/2022, 2:10 PMrusshwolf
09/17/2022, 2:17 PMAbstractKotlinCompile
gets you all platforms if that’s what you needJonas TM
09/17/2022, 2:50 PMfun main() {
with(BasicLogger()) {
test()
}
}
context (LoggingContext)
fun test() {
log("hello world")
}
interface LoggingContext {
fun log(msg: String)
}
class BasicLogger() : LoggingContext {
override fun log(msg: String) {
println(msg)
}
}
But getting the following compile error:
e: java.lang.IllegalStateException: FULL: FUN name:test visibility:public modality:FINAL <> (<this>:de.tm.jonas.LoggingContext) returnType:kotlin.Unit
Ir: de.tm.jonas#test(de.tm.jonas.LoggingContext){}
Descriptor: de.tm.jonas#test!de.tm.jonas.LoggingContext(){}
at org.jetbrains.kotlin.backend.common.serialization.mangle.ManglerChecker$visitDeclaration$2.invoke(ManglerChecker.kt:96)
...
sergey.bogolepov
09/18/2022, 9:01 AMJonas TM
09/18/2022, 9:24 AM