|| $self->throw_error("You must pass an ARRAY ref of roles", data => $options{roles})
if exists $options{roles};
- my $super = delete $options{superclasses};
-
my $class = $self->SUPER::create($package_name, %options);
- if ( my @super = @{ $super || [] } ) {
- $class->_fix_metaclass_incompatibility(@super);
- $class->superclasses(@super);
- }
-
if (exists $options{roles}) {
Moose::Util::apply_all_roles($class, @{$options{roles}});
}
return $class;
}
+sub check_metaclass_compatibility {
+ my $self = shift;
+
+ if ( my @supers = $self->superclasses ) {
+ $self->_fix_metaclass_incompatibility(@supers);
+ }
+
+ $self->SUPER::check_metaclass_compatibility(@_);
+}
+
my %ANON_CLASSES;
sub create_anon_class {
$roles{ $thing . '_roles' } = \@roles;
}
- $self = $self->_reinitialize_with($super_meta);
+ $self->_reinitialize_with($super_meta);
Moose::Util::MetaRole::apply_metaclass_roles(
for_class => $self->name,
--- /dev/null
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 4;
+use Test::Exception;
+
+{
+ package NoOpTrait;
+ use Moose::Role;
+}
+
+{
+ package Parent;
+ use Moose -traits => 'NoOpTrait';
+
+ has attr => (
+ is => 'rw',
+ isa => 'Str',
+ );
+}
+
+{
+ package Child;
+ use base 'Parent';
+}
+
+is(Child->meta->name, 'Child', "correct metaclass name");
+
+my $child = Child->new(attr => "ibute");
+ok($child, "constructor works");
+
+is($child->attr, "ibute", "getter inherited properly");
+
+$child->attr("ition");
+is($child->attr, "ition", "setter inherited properly");