my ($name) = @_;
our %DID_INJECT;
return Class::MOP::get_metaclass_by_name($name) if $DID_INJECT{$name};
- require Moose; require Moo; require Moo::Role;
+ require Moose; require Moo; require Moo::Role; require Scalar::Util;
Class::MOP::remove_metaclass_by_name($name);
my ($am_role, $meta, $attr_specs, $attr_order) = do {
if (my $info = $Moo::Role::INFO{$name}) {
{ @attr_info },
[ @attr_info[grep !($_ % 2), 0..$#attr_info] ]
)
- } else {
- my $specs = Moo->_constructor_maker_for($name)->all_attribute_specs;
+ } elsif ( my $cmaker = Moo->_constructor_maker_for($name) ) {
+ my $specs = $cmaker->all_attribute_specs;
(0, Moose::Meta::Class->initialize($name), $specs,
[ sort { $specs->{$a}{index} <=> $specs->{$b}{index} } keys %$specs ]
);
+ } else {
+ # This codepath is used if $name does not exist in $Moo::MAKERS
+ (0, Moose::Meta::Class->initialize($name), {}, [] )
}
};
my $tc = $spec{isa} = do {
if (my $mapped = $TYPE_MAP{$isa}) {
my $type = $mapped->();
+ Scalar::Util::blessed($type) && $type->isa("Moose::Meta::TypeConstraint")
+ or die "error inflating attribute '$name' for package '$_[0]': \$TYPE_MAP{$isa} did not return a valid type constraint'";
$coerce ? $type->create_child_type(name => $type->name) : $type;
} else {
Moose::Meta::TypeConstraint->new(