codeconsole commented on PR #3025:
URL: https://github.com/apache/groovy/pull/3025#issuecomment-6400424812

   Pushed 073ef08395. Replies in the order of the review:
   
   1. Fixed in 1c7809b1f5: a miss throws a `GroovyBugError` naming the helper 
and the trait, as `Traits.findHelpers` already does for a missing helper class. 
`testPrecompiledTraitHelperWithoutInitializerIsRejected` strips `$init$` from a 
precompiled helper with ASM and expects the error; it fails without the guard. 
`getDeclaredMethod` compares parameter types by class name, so generic, 
`@SelfType` and precompiled traits match 
(`testInitializerOfGenericTraitIsCalledDirectly`, 
`testInitializerOfSelfTypeTraitIsCalledDirectly`, 
`testInitializerOfPrecompiledTraitIsCalledDirectly`).
   2. Done in 9f2c73507e for both `$init$` and `$static$init$`; the 
`$static$init$` call did not set it either, only the forwarders did. The field 
initializer calls from 177b7ccdee set it too. The bytecode is unchanged (38 
class files compared). `safe` is already false by default.
   3. Done in 716bbd9371: the note is on `Traits.INIT_METHOD`, and the JIRA 
description says the same. Runtime trait application has no separate path: 
`ProxyGeneratorAdapter` compiles a `$TraitAdapter` class that `TraitComposer` 
composes like any other class, so on 6.0.0 `withTraits` and `as` also went 
through the meta class, and now they do not. 
`testTraitInitializerIsNotDispatchedThroughMetaClass` covers the compiled 
classes, a `@TypeChecked` class and both runtime forms.
   4. Done in this PR, 177b7ccdee: the field initializers (`$init$<field>`, 
`$static$init$<field>`) are now calls with the helper method as target. Dynamic 
and `@TypeChecked` classes called them with invokedynamic (`@CompileStatic` 
ones were already direct); every mode now emits invokestatic, also against 
traits compiled by Groovy 4.0.24 and 5.0.3, and with indy off. 
`testFieldInitializersOfTraitAreCalledDirectly` and the extended precompiled 
test fail without it.
   5. Added in 073ef08395: 
`testInitializersFollowTheOrderOfTheImplementsClause` (`implements C, B` gives 
B, A, C), `testSubclassCallsTheInitializersOfTheTraitsItDeclares` and 
`testInitializationOrderWithSwappedTraitsAndSuperclass`. The orders match 
6.0.0, including a subclass that declares its superclass's trait again through 
a sub-trait and so initializes its own copy of that trait's fields, as 
`_traits.adoc` describes.
   6. Added in 073ef08395: `testInitializerIsCalledDirectlyFromAnonymousClass` 
checks the constructors of anonymous classes created in a method and in a 
closure.
   
   Test gaps:
   - `$init$` that cannot be resolved: 
`testPrecompiledTraitHelperWithoutInitializerIsRejected` (1c7809b1f5).
   - Declaration order and superclass/subclass traits: item 5.
   - `new Greeting() {}`: item 6.
   - `@CompileStatic` trait with field initializers: 
`testStaticallyCompiledTraitIsInitializedDirectly` (073ef08395), with dynamic, 
`@TypeChecked` and `@CompileStatic` implementers; it also checks that the 
trait's own `$init$` makes no dynamic call.
   
   Nits:
   - The note on `Traits.INIT_METHOD` names GROOVY-12491. The sibling constants 
in `Traits` carry no `@since`, so none was added.
   - Done in 073ef08395: the assertions also reject an invokedynamic call site 
whose bootstrap arguments name an initializer, and cover the field initializers.
   - Kept; the new precompiled test uses the same pattern.
   
   `TraitInitBytecodeTest` now has 47 tests; with the pre-PR `TraitComposer`, 
37 fail. 14,443 tests pass on JDK 21, and `bugs.Groovy12142`, 
`bugs.Groovy12363` and `TraitInitBytecodeTest` on JDK 17.
   


-- 
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