[ 
https://issues.apache.org/jira/browse/GROOVY-12841?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18152306#comment-18152306
 ] 

ASF GitHub Bot commented on GROOVY-12841:
-----------------------------------------

codeconsole opened a new pull request, #3369:
URL: https://github.com/apache/groovy/pull/3369

   Javadoc only. `CompilerConfiguration.CLOSURE_PACKING` and `@PackedClosures` 
say the `groovy.target.closure.pack` flag packs provably-safe `@CompileStatic` 
closures. With the flag set, a dynamically compiled closure whose body has no 
free name is packed too:
   
   ```groovy
   class Dyn {
       static void main(String[] args) {
           Closure c = { String s -> s.length() }
           println c.getClass().name      // 
org.codehaus.groovy.runtime.PackedClosure$Fixed1 with the flag
       }
   }
   ```
   
   That is intended (`ClosureWriter#isPackTriggered`, the GROOVY-12151 
syntactic path; 
`ClosurePackCapabilityTest#dynamicDelegateIndependentClosuresAutoPackBySyntax` 
asserts it), so the two public Javadocs now state both subsets: under 
`@CompileStatic`, closures the type checker resolved without a delegate; under 
dynamic compilation, closures whose body has no free name.
   
   Not changed: the first sentence of the Javadoc of 
`ClosureWriter#isPackTriggered` and the class comment of 
`ClosurePackCapabilityTest` say the same outdated thing.
   
   https://issues.apache.org/jira/browse/GROOVY-12841
   




> Javadoc of CompilerConfiguration.CLOSURE_PACKING and @PackedClosures says the 
> flag packs only @CompileStatic closures
> ---------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12841
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12841
>             Project: Groovy
>          Issue Type: Bug
>          Components: Documentation
>    Affects Versions: 6.0.0, 6.0.1
>            Reporter: Scott Murphy Heiberg
>            Priority: Blocker
>
> CompilerConfiguration.CLOSURE_PACKING is documented as
> {quote}
> System-property name for the GEP-27 incubating option that automatically 
> packs provably-safe @CompileStatic closures (hoisting their bodies to a 
> shared adapter instead of a class).
> {quote}
> and the Javadoc of groovy.transform.PackedClosures says "Automatic packing of 
> provably-safe @CompileStatic closures — without this annotation — is 
> available behind the groovy.target.closure.pack flag".
> With the property set, dynamically compiled closures are packed too when 
> their body has no free name:
> {code:groovy}
> class Dyn {
>     static void main(String[] args) {
>         Closure c = { String s -> s.length() }
>         println c.getClass().name
>     }
> }
> {code}
> {noformat}
> $ java -Dgroovy.target.closure.pack=true -cp groovy-6.0.1.jar 
> groovy.ui.GroovyMain Dyn.groovy
> org.codehaus.groovy.runtime.PackedClosure$Fixed1
> {noformat}
> The behaviour is intended: ClosureWriter#isPackTriggered packs a dynamic 
> closure that isSyntacticallyDelegateIndependent ("GROOVY-12151 dynamic 
> syntactic path"), and 
> ClosurePackCapabilityTest#dynamicDelegateIndependentClosuresAutoPackBySyntax 
> asserts it. The documentation is what is out of date. The first sentence of 
> the Javadoc of ClosureWriter#isPackTriggered ("the only trigger is the 
> @PackedClosures trust assertion") and the class comment of 
> ClosurePackCapabilityTest ("dynamic closures (no static resolution) are never 
> auto-packed") say the same outdated thing.
> Proposed fix (pull request to follow)
> State both subsets in the two public Javadocs: under @CompileStatic, closures 
> the type checker resolved without a delegate; under dynamic compilation, 
> closures whose body has no free name (no implicit-this call and no name other 
> than a parameter or local variable).



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to