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

   When Groovy and Java sources are compiled together, a trait's instance 
initializer blocks now run once per instance. Before, `trait T { List<String> 
log = []; { log << 'block' } }` gave `[block, block]` with `-j`, for dynamic 
and `@CompileStatic` implementing classes alike.
   
   The stub generator runs a `Verifier` over each class. `Verifier.visitClass` 
clears the object initializer statements of a class after copying them into its 
constructors, so `JavaStubGenerator` saves them first and adds them back 
afterwards. For an interface or a trait, `visitClass` returns before that point 
and keeps them, so adding them back doubled them, and the trait transformation 
copied every block into the helper's `$init$` twice. The stub generator now 
restores exactly the statements it saved. Field initializers and static 
initializer blocks of traits were not affected.
   
   Tests: `stubgenerator.Groovy12575`, which fails without the change. The 
`groovy`, `gls`, `bugs` and `org.codehaus.groovy` packages pass (15,496 tests), 
apart from five tests whose `@Grab` downloads failed while other builds ran; 
they pass when rerun. The Checkstyle and CodeNarc gates pass.
   
   Seen in 4.0.33, 5.0.8 and 6.0.0.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to