Subject: | Unable to override Moose::Role method in Moose subclass |
I am trying to override in a Moose class that is originally defined in a Moose::Role. The Moose class is a direct implementer of the Role. When trying to do this, I get the error 'Cannot add an override method if a local method is already present' even though the method is not defined in the Moose class. Here is an example that will generate the error:
package AbstractClass;
use Moose::Role;
sub my_ac_sub {
my $self = shift;
print "In AbstractClass!\n";
return;
}
1;
package Class;
use Moose;
with 'AbstractClass';
override 'my_ac_sub' => sub {
my $self = shift;
super;
print "In Class!\n";
return;
};
__PACKAGE__->meta->make_immutable;
1;
use Class;
my $class = Class->new;
$class->my_ac_sub;
I expect to see:
In AbstractClass!
In Class!
- but instead I get the error mentioned above. Please let me know if you need more detail.