Can somebody help me with the `org.jetbrains.kotli...
# scripting
a
Can somebody help me with the
org.jetbrains.kotlin:kotlin-scripting-jvm
library? I'm trying to run a very basic script, but I get two errors, when I should get none. This is my script:
Copy code
1
I expect to get back a
ResultWithDiagnostics.Success
with a
resultValue
of
1
but instead I get a
Failure
, with these reports: 1.
The expression is unused
2.
wrong number of arguments
Even if I fix the warning by modifying my script to
Copy code
class Foo(val foo: String = "foo")

Foo()
I still get the
wrong number of arguments
error. I checked the source and it seems that in
BasicJvmScriptEvaluator:95
Copy code
return try {
            ctor.newInstance(*args.toArray()) <-- here
        } finally {
            Thread.currentThread().contextClassLoader = saveClassLoader
        }
args
is empty. What am I doing wrong? This is how I try to run the script:
Copy code
private fun evalFile(scriptFile: File): ResultWithDiagnostics<EvaluationResult> {
    val compilationConfiguration = createJvmCompilationConfigurationFromTemplate<TestScript> {
        jvm {
            dependenciesFromCurrentContext(wholeClasspath = true)
        }
    }

    return BasicJvmScriptingHost().eval(scriptFile.toScriptSource(), compilationConfiguration, null)
}