Scalar::Util::weaken $METAS{$package_name}
if $mortal;
- $meta->add_method(meta => sub{
+ $meta->add_method(meta => sub {
$self->initialize(ref($_[0]) || $_[0]);
});
return;
}
- if($method_name ne 'meta'){
+ if($method_name eq 'meta'){
+ $self->SUPER::add_method($method_name => $code);
+ }
+ else{
+ # no need to add a subroutine to the stash
my $roles = $self->{composed_roles_by_method}{$method_name} ||= [];
push @{$roles}, $role;
if(@{$roles} > 1){
$self->{conflicting_methods}{$method_name}++;
}
+ $self->{methods}{$method_name} = $code;
}
-
- $self->{methods}{$method_name} = $code;
- # no need to add a subroutine to the stash
return;
}
use strict;
use warnings;
-use Test::More tests => 4;
+use Test::More;
use Mouse::Util qw(does_role);
use Mouse -traits => qw(BarTrait);
extends qw(BaseClass);
+
+ package SubSubClass;
+ use Mouse;
+
+ extends qw(SubClass);
}
ok does_role(BaseClass->meta, 'FooTrait'), ' BaseClass->meta->does("FooTrait")';
ok does_role(SubClass->meta, 'FooTrait'), 'SubClass->meta->does("FooTrait")';
ok does_role(SubClass->meta, 'BarTrait'), 'SubClass->meta->does("BarTrait")';
+ok does_role(SubSubClass->meta, 'FooTrait'), 'SubSubClass->meta->does("FooTrait")';
+ok does_role(SubSubClass->meta, 'BarTrait'), 'SubSubClass->meta->does("BarTrait")';
+
+done_testing;