Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.5.5
-
None
Description
With ref. to GROOVY-8880, it seems Instance Init Blocks in Traits are appended/called only when there are fields defined in the same trait.
Example:
trait TraitOne { { System.out.println("Does not work") } } trait TraitTwo { Integer instanceCounter //immutable, non-shareable { System.out.println("Works") instanceCounter = 1 } } class ClassWithTrait implements TraitOne, TraitTwo { } new ClassWithTrait().instanceCounter
Output:
Works
Expected output (order may differ):
Works Does not work
Attachments
Issue Links
- relates to
-
GROOVY-8891 Trait Instance Init Block causes Runtime exception for Trait fields with default values
- Closed
-
GROOVY-8880 Traits - static/instance init blocks
- Closed