Moo: inheritance conflicting with role composition?

[email protected] (Diab Jerius) Wed, 7 Jan 2015 14:18:20 -0500
Newsgroups perl.moose
Message-ID <CADpyd5CfPd=8-Bb5EjCd9a-xhyA3ns8-MQ93dkr7e6HWUVSHBg@mail.gmail.com>
--047d7bfea2f6c74057050c14cb11
Content-Type: text/plain; charset=UTF-8

Hi!

I've attached some example code which exhibits (to my thinking) an
unexpected collision between inheritance and composition. I'm using
Moo v. 1.006001.

There is a base role (R0) which provides a method, track().

The role is consumed by another role (R1) which is consumed by a class
(C1), each of which modifies track().

C1->new->track exhibits the correct series of modifications.

C2 is a class which inherits from C1 and also modifies track().

C2->new->track also exhibits the correct behavior with regard to the
modifications.

C3 is a class which inherits from C1, modifies track(), and consumes R0.

C3->new->track seems to completely ignore its parent class.

The code outputs the packages whose modification was performed.  I'm
getting this

C1:     R1    C1
C2:     R1    C1    C2
C3:     C3

I expected the result for C3 to be

C3:     R1    C1    C3

The order of C3's consumption of R0 and extension of C1 doesn't change
the results.

What confuses me is that track() calls up the inheritance chain, so
that any version of track() which ends up in C3 should know enough to
call C1's track, and thus see the modifications made at that level.

Please let me know if I'm missing something here!

Thanks,

Diab

--047d7bfea2f6c74057050c14cb11
Content-Type: application/x-perl; name="tst.pl"
Content-Disposition: attachment; filename="tst.pl"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_i4n34gr70

IyFwZXJsCgp1c2UgNS4xMC4wOwoKc3ViIHVwZGF0ZV90cmFjayB7CiAgICBteSAkb3JpZyA9IHNo
aWZ0OwogICAgbXkgJHRhcmdldCA9IGNhbGxlcjsKICAgIHJldHVybiAmJG9yaWcsICR0YXJnZXQ7
Cn0KCnBhY2thZ2UgUjAgewoKICAgIHVzZSBNb286OlJvbGU7CgogICAgc3ViIHRyYWNrIHsgc2hp
ZnQtPm1heWJlOjpuZXh0OjptZXRob2QoIEBfICk7IH0KfQoKcGFja2FnZSBSMSB7CgogICAgdXNl
IE1vbzo6Um9sZTsKICAgIHdpdGggJ1IwJzsKCiAgICBhcm91bmQgdHJhY2sgPT4gc3ViIHsgJjo6
dXBkYXRlX3RyYWNrIH07Cn0KCnBhY2thZ2UgQzEgewoKICAgIHVzZSBNb287CiAgICB3aXRoICdS
MSc7CgogICAgYXJvdW5kIHRyYWNrID0+IHN1YiB7ICY6OnVwZGF0ZV90cmFjayB9Owp9CgpwYWNr
YWdlIEMyIHsKCiAgICB1c2UgTW9vOwogICAgZXh0ZW5kcyAnQzEnOwoKICAgIGFyb3VuZCB0cmFj
ayA9PiBzdWIgeyAmOjp1cGRhdGVfdHJhY2sgfTsKfQoKcGFja2FnZSBDMyB7CgogICAgdXNlIE1v
bzsKICAgIHdpdGggJ1IwJzsKICAgIGV4dGVuZHMgJ0MxJzsKCiAgICBhcm91bmQgdHJhY2sgPT4g
c3ViIHsgJjo6dXBkYXRlX3RyYWNrIH07Cn0KCgokLCA9ICJcdCI7CgpzYXkgIkMxOiAiLCBDMS0+
bmV3LT50cmFjazsKc2F5ICJDMjogIiwgQzItPm5ldy0+dHJhY2s7CnNheSAiQzM6ICIsIEMzLT5u
ZXctPnRyYWNrOwoK
--047d7bfea2f6c74057050c14cb11--