Olaf Gottschalk
08/06/2024, 5:57 AMfreeCompiler
arguments for the Kotlin tasks. But now, I seem to have reached yet another level: I added one specific DSL extension function to my language that needs to use a context receiver for the DSL language itself - and compiling it using the script compiler yields the known message:
ERROR To use contextual declarations, specify the `-Xcontext-receivers` compiler option (unnamed.trala.kts:3:1)
The way I use the compiler internally is this function I wrote:
fun evalTransformation(script: String, name: String?): ResultWithDiagnostics<EvaluationResult> {
val compilationConfiguration = createJvmCompilationConfigurationFromTemplate<TralaScript>()
return BasicJvmScriptingHost().eval(script.toScriptSource(name), compilationConfiguration, null)
}
@KotlinScript(fileExtension = "trala.kts", compilationConfiguration = TralaScriptConfiguration::class)
abstract class TralaScript
object TralaScriptConfiguration : ScriptCompilationConfiguration(
{
defaultImports(tralaDefaultImports)
jvm {
jvmTarget("11")
updateClasspath(...)
}
}
)
I am searching, but not finding... which element here would be the key to enabling the context receivers? Is it the compilationConfiguration, so my own ScriptCompilationConfiguration
that I defined, or is it the BasicJvmScriptingHost
first parameter, named baseHostConfiguration
? Do I find a named function called "contextReceivers" anywhere or do I need to pull tricks somewhere?
Any help is appreciated!