Use an inlined constraint when checking member values for native collection
Dave Rolsky [Sun, 10 Apr 2011 23:56:00 +0000 (18:56 -0500)]
lib/Moose/Meta/Method/Accessor/Native/Collection.pm

index c358730..377bc13 100644 (file)
@@ -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: "'