+ - fix warnings about unknown attribute parameters on metaclass inflation
- don't pass 'handles' down when doing 'has +' to avoid unDWIMmy explosions
- throw a useful exception when typemap doesn't return a value
- avoid localising @_ when not required for Sub::Quote
Sub::Defer::undefer_sub($_) for grep defined, values %methods;
my @attrs;
{
+ my %spec_map = (
+ map { $_->name => $_->init_arg }
+ grep { $_->has_init_arg }
+ $meta->attribute_metaclass->meta->get_all_attributes
+ );
# This local is completely not required for roles but harmless
local @{_getstash($name)}{keys %methods};
my %seen_name;
foreach my $name (@$attr_order) {
$seen_name{$name} = 1;
my %spec = %{$attr_specs->{$name}};
- delete $spec{index};
$spec{is} = 'ro' if $spec{is} eq 'lazy' or $spec{is} eq 'rwp';
- delete $spec{asserter};
my $coerce = $spec{coerce};
if (my $isa = $spec{isa}) {
my $tc = $spec{isa} = do {
$spec{isa} = $tc;
$spec{coerce} = 1;
}
+ %spec =
+ map { $spec_map{$_} => $spec{$_} }
+ grep { exists $spec_map{$_} }
+ keys %spec;
push @attrs, $meta->add_attribute($name => %spec);
}
foreach my $mouse (do { our %MOUSE; @{$MOUSE{$name}||[]} }) {
$spec->{documentation} .= 'child';
});
}
+BEGIN{
+ local $SIG{__WARN__} = sub { fail "warning: $_[0]" };
+ package SplatteredMoose;
+ use Moose;
+ extends 'Splattered';
+}
foreach my $s (
Splattered->new,
Ker::Splattered2->new,
KerSplattered->new,
KerSplattered2->new,
+ SplatteredMoose->new
) {
- ok($s->can('punch'))
+ can_ok($s, 'punch')
and is($s->punch, 1, 'punch');
- ok($s->can('jab'))
+ can_ok($s, 'jab')
and is($s->jab, 3, 'jab');
- ok($s->can('monkey'))
+ can_ok($s, 'monkey')
and is($s->monkey, 'OW', 'monkey');
- ok($s->can('trap'))
+ can_ok($s, 'trap')
and is($s->trap, -1, 'trap');
}
KerSplattered
KerSplattered2
/) {
- ok $c->can('has_ker');
- ok $c->can('has_splat');
+ can_ok($c, 'has_ker');
+ can_ok($c, 'has_splat');
}
is(Plunker->meta->find_attribute_by_name('pp')->documentation, 'moosify', 'moosify modifies attr specs');
);
__PACKAGE__->meta->make_immutable
}
+{
+ package MooChild;
+ use Moo;
+ extends 'MooParent';
+
+ has '+foo' => (
+ default => sub { 'MooChild' },
+ );
+}
is(
MooseChild->new->foo,
'default value in Moose child'
);
+is(exception {
+ local $SIG{__WARN__} = sub { die $_[0] };
+ ok(MooChild->meta->has_attribute('foo'), 'inflated metaclass has overridden attribute');
+}, undef, 'metaclass inflation of plus override works without warnings');
+
done_testing;