MarcHadfield
2015-01-30 14:58:51 UTC
Hello all -
when defined at runtime, stackable traits don't seem to honor the order in
withTraits(), whereas when defined statically they do. This seems to be a
groovy bug. I don't have a JIRA account, but otherwise I would be glad to
report it in JIRA. Can someone please add this to JIRA or an admin add an
account for me?
Sample code with output follows.
Thanks!
Code:
trait D {
void methodA() { print "D"; super.methodA() }
}
trait C {
void methodA() { print "C"; super.methodA() }
}
trait B {
void methodA() { print "B"; super.methodA() }
}
trait A {
void methodA() { print "A" }
}
class M implements A, D, C, B { }
class Q {}
class MyDelegationTest {
static main(args) {
println ""
def m = new M()
print "Static: "
m.methodA()
println ""
def q = new Q().withTraits(A,D,C,B)
print "Dynamic: "
q.methodA()
println ""
}
}
With output:
(Correct Order) Static: BCDA
(Incorrect Order) Dynamic: DCBA
-- Marc
--
View this message in context: http://groovy.329449.n5.nabble.com/Stackable-Traits-at-runtime-don-t-honor-definition-order-tp5722333.html
Sent from the groovy - dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
when defined at runtime, stackable traits don't seem to honor the order in
withTraits(), whereas when defined statically they do. This seems to be a
groovy bug. I don't have a JIRA account, but otherwise I would be glad to
report it in JIRA. Can someone please add this to JIRA or an admin add an
account for me?
Sample code with output follows.
Thanks!
Code:
trait D {
void methodA() { print "D"; super.methodA() }
}
trait C {
void methodA() { print "C"; super.methodA() }
}
trait B {
void methodA() { print "B"; super.methodA() }
}
trait A {
void methodA() { print "A" }
}
class M implements A, D, C, B { }
class Q {}
class MyDelegationTest {
static main(args) {
println ""
def m = new M()
print "Static: "
m.methodA()
println ""
def q = new Q().withTraits(A,D,C,B)
print "Dynamic: "
q.methodA()
println ""
}
}
With output:
(Correct Order) Static: BCDA
(Incorrect Order) Dynamic: DCBA
-- Marc
--
View this message in context: http://groovy.329449.n5.nabble.com/Stackable-Traits-at-runtime-don-t-honor-definition-order-tp5722333.html
Sent from the groovy - dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email