Does anyone here know how, or if it is possible, t...
# announcements
n
Does anyone here know how, or if it is possible, to use the new type inference when compiling scripts with the embedded compiler?
Or perhaps more generally... How do I pass "-X" arguments programmatically to the embeddable compiler?
m
@nickheitz Hello! Does not “-XXLanguage:+NewInference” help?
n
That's is indeed what I would use from the command line. However the scenario I need is dynamic compilation of scripts via the jsr223 APIs. I have no trouble compiling dynamic classes with these APIs, but I haven't figured out how to leverage compiler switches like the above.
Perhaps this will be of benefit to someone: Found a solution using the new experimental script compiler via the "ScriptingHost" example and some massive guesswork. It seems the following works:
Copy code
createJvmCompilationConfigurationFromTemplate<SimpleScript> {
    jvm {
        compilerOptions.append("-jvm-target")
        compilerOptions.append("1.8")
        compilerOptions.append("-Xnew-inference")
        compilerOptions.append("-Xinline-classes")
        dependenciesFromCurrentContext(
                wholeClasspath = true
        )
    }
}
The above will build a compilation classpath, enable new inference and inline classes, plus, critically, set the right jvm target. Guess I'm glad I got there in the end.