From: Dave Rolsky Date: Sun, 10 Apr 2011 23:56:00 +0000 (-0500) Subject: Use an inlined constraint when checking member values for native collection X-Git-Tag: 2.0100~76 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=31056177e5cdb38effdf41112e07587e6d9c11c6;p=gitmo%2FMoose.git Use an inlined constraint when checking member values for native collection --- diff --git a/lib/Moose/Meta/Method/Accessor/Native/Collection.pm b/lib/Moose/Meta/Method/Accessor/Native/Collection.pm index c358730..377bc13 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/Collection.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Collection.pm @@ -97,9 +97,14 @@ sub _inline_check_member_constraint { my $attr_name = $self->associated_attribute->name; + my $check + = $self->_tc_member_type->has_inlined_type_constraint + ? '! (' . $self->_tc_member_type->_inline_check('$_') . ')' + : ' !$member_tc->($_) '; + return ( 'for (' . $new_value . ') {', - 'if (!$member_tc->($_)) {', + "if ($check) {", $self->_inline_throw_error( '"A new member value for ' . $attr_name . ' does not pass its type constraint because: "'