[ https://issues.apache.org/jira/browse/GROOVY-7500?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15137807#comment-15137807 ]
Jeff Scott Brown commented on GROOVY-7500: ------------------------------------------ Is it agreed that this behavior is a bug? > Problem With Runtime Metaprogramming Over A Trait Method > -------------------------------------------------------- > > Key: GROOVY-7500 > URL: https://issues.apache.org/jira/browse/GROOVY-7500 > Project: Groovy > Issue Type: Bug > Affects Versions: 2.4.3 > Reporter: Jeff Scott Brown > Attachments: metaprogramovertrait.zip > > > It looks like I cannot runtime metaprogram over a trait method. > The attached metaprogramovertrait.zip file contains the following: > {code:title=src/main/groovy/demo/SomeClass.groovy} > package demo > class SomeClass implements SomeTrait {} > {code} > {code:title=src/main/groovy/demo/SomeTrait.groovy} > package demo > trait SomeTrait { > void someMethod() { > } > } > {code} > {code:title=src/test/groovy/demo/SomeClassSpec.groovy} > package demo > import spock.lang.Specification > class SomeClassSpec extends Specification { > void 'test something'() { > given: > SomeClass.metaClass.someMethod = { -> > throw new UnsupportedOperationException() > } > when: > new SomeClass().someMethod() > then: > UnsupportedOperationException ex = thrown() > } > } > {code} > If I remove the method from the trait, the test passes. -- This message was sent by Atlassian JIRA (v6.3.4#6332)