I have an application Groovyin which I allow the user to add custom behavior through scripts Groovy. I include these scripts through GroovyShelland test them through Type Checking Extensions. Full code of how I include the script in my application:
def config = new CompilerConfiguration()
config.addCompilationCustomizers(
new ASTTransformationCustomizer(TypeChecked)
)
def shell = new GroovyShell(config)
shell.evaluate(new File("path/to/some/file.groovy"))
It works great. However , type checking in a script seems seriously broken. For example, I can include the following scripts without any compiler complaint:
String test = getTestValue()
println "The value is $test"
private Integer getTestValue(){
return 0
}
I can even go further. When creating classinside a script, I can assign it Stringwithout errors:
String y = new Test()
println y // shows Test@somenr on the console
class Test { }
do . , .