From: Dave Rolsky Date: Fri, 19 Nov 2010 15:16:53 +0000 (-0600) Subject: Merge branch 'topic/native-trait-bugfix' X-Git-Tag: 1.9900~25 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3a4e6199df4974e6223bb35a9f3b8572c40d5a7d;p=gitmo%2FMoose.git Merge branch 'topic/native-trait-bugfix' Conflicts: Changes lib/Moose/Meta/Method/Accessor/Native/Collection.pm --- 3a4e6199df4974e6223bb35a9f3b8572c40d5a7d diff --cc Changes index e73dbcd,4501c9b..a99d871 --- a/Changes +++ b/Changes @@@ -3,22 -3,12 +3,28 @@@ for, noteworthy changes NEXT + [API CHANGES] + + * Roles now have their own default attribute metaclass to use during + application to a class, rather than just using the class's + attribute_metaclass. This is also overridable via ::MetaRole, with the + applied_attribute key in the role_metaroles hashref (doy). + + * The internal code used to generate inlined methods (accessor, constructor, + etc.) has been massively rewritten. MooseX modules that do inlining will + almost certainly need to be updated as well. + + [ENHANCEMENTS] + + * We now load the roles needed for native delegations only as needed. This + speeds up the compilation time for Moose itself. (doy) + + [BUG FIXES] + + * When using native delegations, if an array or hash ref member failed a + type constraint check, Moose ended up erroring out with "Can't call method + "get_message" on unblessed reference" instead of generating a useful error + based on the failed type constraint. Reported by t0m. (Dave Rolsky) 1.19 Tue, Nov 2, 2010 diff --cc lib/Moose/Meta/Method/Accessor/Native/Collection.pm index 5e75523,1721523..26cf3c5 --- a/lib/Moose/Meta/Method/Accessor/Native/Collection.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Collection.pm @@@ -101,33 -105,27 +101,33 @@@ sub _inline_check_member_constraint my $attr_name = $self->associated_attribute->name; - return '$member_tc->($_) || ' - . $self->_inline_throw_error( - qq{"A new member value for '$attr_name' does not pass its type constraint because: "} - . ' . $member_tc_obj->get_message($_)', - "data => \$_" - ) . " for $new_value;"; + return ( + 'for (' . $new_value . ') {', + 'if (!$member_tc->($_)) {', + $self->_inline_throw_error( + '"A new member value for ' . $attr_name + . ' does not pass its type constraint because: "' - . ' . $member_tc->get_message($_)', ++ . ' . $member_tc_obj->get_message($_)', + 'data => $_', + ) . ';', + '}', + '}', + ); } -around _inline_get_old_value_for_trigger => sub { - shift; - my ( $self, $instance ) = @_; +sub _inline_get_old_value_for_trigger { + my $self = shift; + my ($instance, $old) = @_; my $attr = $self->associated_attribute; - return '' unless $attr->has_trigger; + return unless $attr->has_trigger; - return - 'my @old = ' - . $self->_inline_has($instance) . q{ ? } - . $self->_inline_copy_old_value( $self->_inline_get($instance) ) - . ": ();\n"; -}; + return ( + 'my ' . $old . ' = ' . $self->_has_value($instance), + '? ' . $self->_copy_old_value($self->_get_value($instance)), + ': ();', + ); +} around _eval_environment => sub { my $orig = shift;