[jira] [Commented] (GROOVY-8892) Trait instance init blocks are called only when there are fields defined in same Trait
[ https://issues.apache.org/jira/browse/GROOVY-8892?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16690994#comment-16690994 ] Anton Pryamostanov commented on GROOVY-8892: [~paulk] FYI kindly > Trait instance init blocks are called only when there are fields defined in > same Trait > -- > > Key: GROOVY-8892 > URL: https://issues.apache.org/jira/browse/GROOVY-8892 > Project: Groovy > Issue Type: Bug > Components: Compiler, groovy-runtime >Affects Versions: 2.5.5 >Reporter: Anton Pryamostanov >Priority: Major > > 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: > {code} > 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 > {code} > Output: > {code} > Works > {code} > Expected output (order may differ): > {code} > Works > Does not work > {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (GROOVY-8892) Trait instance init blocks are called only when there are fields defined in same Trait
[ https://issues.apache.org/jira/browse/GROOVY-8892?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16692795#comment-16692795 ] Anton Pryamostanov commented on GROOVY-8892: Retested OK in 2.5.5.SNAPSHOT > Trait instance init blocks are called only when there are fields defined in > same Trait > -- > > Key: GROOVY-8892 > URL: https://issues.apache.org/jira/browse/GROOVY-8892 > Project: Groovy > Issue Type: Bug > Components: Compiler, groovy-runtime >Affects Versions: 2.5.5 >Reporter: Anton Pryamostanov >Assignee: Paul King >Priority: Major > Fix For: 3.0.0-alpha-4, 2.5.5 > > > 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: > {code} > 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 > {code} > Output: > {code} > Works > {code} > Expected output (order may differ): > {code} > Works > Does not work > {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (GROOVY-8892) Trait instance init blocks are called only when there are fields defined in same Trait
[ https://issues.apache.org/jira/browse/GROOVY-8892?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16693796#comment-16693796 ] Anton Pryamostanov commented on GROOVY-8892: Retested OK in 3.0.0.SNAPSHOT > Trait instance init blocks are called only when there are fields defined in > same Trait > -- > > Key: GROOVY-8892 > URL: https://issues.apache.org/jira/browse/GROOVY-8892 > Project: Groovy > Issue Type: Bug > Components: Compiler, groovy-runtime >Affects Versions: 2.5.5 >Reporter: Anton Pryamostanov >Assignee: Paul King >Priority: Major > Fix For: 3.0.0-alpha-4, 2.5.5 > > > 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: > {code} > 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 > {code} > Output: > {code} > Works > {code} > Expected output (order may differ): > {code} > Works > Does not work > {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (GROOVY-8892) Trait instance init blocks are called only when there are fields defined in same Trait
[ https://issues.apache.org/jira/browse/GROOVY-8892?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16694229#comment-16694229 ] Paul King commented on GROOVY-8892: --- Thanks for retesting those! > Trait instance init blocks are called only when there are fields defined in > same Trait > -- > > Key: GROOVY-8892 > URL: https://issues.apache.org/jira/browse/GROOVY-8892 > Project: Groovy > Issue Type: Bug > Components: Compiler, groovy-runtime >Affects Versions: 2.5.5 >Reporter: Anton Pryamostanov >Assignee: Paul King >Priority: Major > Fix For: 3.0.0-alpha-4, 2.5.5 > > > 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: > {code} > 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 > {code} > Output: > {code} > Works > {code} > Expected output (order may differ): > {code} > Works > Does not work > {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)