Subject: | subclass attribute overrides kill method modifiers |
Adding an override to an attribute seems to kill method modifiers
supplied in the superclass. Here's an example:
package Foo {
use Moose;
has 'foo' => (
is => 'rw',
isa => 'Str',
);
before 'foo' => sub {
my $self = shift;
print "before foo for a " . ref($self) . "\n";
};
};
package FooChild {
use Moose;
extends 'Foo';
has '+foo' => ( default => 49 );
};
my $f = Foo->new();
$f->foo();
my $fc = FooChild->new();
$fc->foo(10);
This prints just "before foo for a Foo" -- there is no call to the
"before" method for the FooChild. But if you comment out the "has
'+foo'" line, the method modifier runs just fine for FooChild.
This problem is also described here:
http://stackoverflow.com/questions/12363971/perl-moose-triggers-in-subclasses-disrupt-method-modifiers
I've tried this with 2.0402 and 2.0603, and see the same problem. Both
were tested with Perl 5.14.2.