You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Jeff Scott Brown (JIRA)" <ji...@apache.org> on 2015/07/11 21:35:04 UTC
[jira] [Created] (GROOVY-7500) Problem With Runtime Metaprogramming
Over A Trait Method
Jeff Scott Brown created GROOVY-7500:
----------------------------------------
Summary: 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
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)