You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2020/07/23 14:17:06 UTC

[jira] [Closed] (GROOVY-9558) Wrong code for putAt on Map that is member of closure delegate

     [ https://issues.apache.org/jira/browse/GROOVY-9558?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul King closed GROOVY-9558.
-----------------------------

> Wrong code for putAt on Map that is member of closure delegate
> --------------------------------------------------------------
>
>                 Key: GROOVY-9558
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9558
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation
>    Affects Versions: 3.0.3, 2.5.12
>         Environment: Oracle JDK8 1.8.0_162, IntelliJ CE 2019.3.4, indy enabled
>            Reporter: Jochen Eddelbuettel
>            Assignee: Eric Milles
>            Priority: Minor
>             Fix For: 4.0.0-alpha-1, 3.0.5, 2.5.13
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
>  
> I'm compiling this little Closure with @CompileStatic enabled
> {code:java}
> scriptEngine.config.tap {
>   // Code generation goes wrong here    
>   optimizationOptions["indy"] = true
>   // This code is generated correctly
>   optimizationOptions.indy = true
> }{code}
> {code:java}
> // 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");
> {code}
> 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'



--
This message was sent by Atlassian Jira
(v8.3.4#803005)