Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.4.3
-
None
-
None
Description
It looks like I cannot runtime metaprogram over a trait method.
The attached metaprogramovertrait.zip file contains the following:
src/main/groovy/demo/SomeClass.groovy
package demo class SomeClass implements SomeTrait {}
src/main/groovy/demo/SomeTrait.groovy
package demo
trait SomeTrait {
void someMethod() {
}
}
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() } }
If I remove the method from the trait, the test passes.