Subject: | Bug with overwride on class_has |
Using 'override' caused a bug
Moose version 2.0008
Here is how to replicate (also as a gist: https://gist.github.com/1471606);
-----
package My::Base;
use Moose;
use MooseX::ClassAttribute;
class_has 'foo' =>
( is => 'rw',
isa => 'Str',
lazy_build => 1,
);
sub _build_foo { die "setup in child" };
__PACKAGE__->meta()->make_immutable();
no Moose;
no MooseX::ClassAttribute;
package My::A;
use Moose;
use MooseX::ClassAttribute;
extends 'My::Base';
override '_build_foo' => sub { return 'a' };
package My::B;
use Moose;
use MooseX::ClassAttribute;
extends 'My::Base';
override '_build_foo' => sub { return 'b' };
package main;
my $a = My::A->new();
my $b = My::B->new();
print "A -> " . $a->foo() . "\n";
print "B -> " . $b->foo() . "\n";
--------
Result:
Show quoted text
>perl test.pl
A -> a
B -> a