Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
3.0.3, 2.5.12
-
None
-
Oracle JDK8 1.8.0_162, IntelliJ CE 2019.3.4, indy enabled
Description
I'm compiling this little Closure with @CompileStatic enabled
scriptEngine.config.tap { // Code generation goes wrong here optimizationOptions["indy"] = true // This code is generated correctly optimizationOptions.indy = true }
// Generated fault code - obviously no call to getOptimizationOptions() boolean var2 = true;DefaultGroovyMethods.putAt(((Class)((_main_closure1)this).getDelegate()).cast<invokedynamic>(((_main_closure1)this).getDelegate()), "indy", var2); // Correct code for the second line, via setProperty boolean bool1 = true;ScriptBytecodeAdapter.setProperty(Boolean.valueOf(bool1), null, ((CompilerConfiguration)((_main_closure1)this).getDelegate()).getOptimizationOptions(), (String)"indy");
Compilation works, but I get a runtime error, which is easily explicable given the generated code:
Exception in thread "main" org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'org.codehaus.groovy.control.CompilerConfiguration@15d9bc04' with class 'org.codehaus.groovy.control.CompilerConfiguration' to class 'java.util.Map'