X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMouse%2FMeta%2FMethod%2FAccessor.pm;h=9b2d92b69767a6c65d639da79adb6a06499041e1;hb=a8391b1105f66a71c29b57fd441d0c02f1897e54;hp=9c5b746a3bf6b02e0949cc362a74e0f3831067a3;hpb=95ecd6f132112c6763cdaf2e6bc72c39e9ab76b5;p=gitmo%2FMouse.git diff --git a/lib/Mouse/Meta/Method/Accessor.pm b/lib/Mouse/Meta/Method/Accessor.pm index 9c5b746..9b2d92b 100755 --- a/lib/Mouse/Meta/Method/Accessor.pm +++ b/lib/Mouse/Meta/Method/Accessor.pm @@ -94,8 +94,11 @@ sub _generate_accessor{ } elsif(defined $constraint){ $accessor .= "my \$tmp = $value;\n"; + #XXX: The following 'defined and' check is for backward compatibility + $accessor .= "defined(\$tmp) and "; + $accessor .= "\$compiled_type_constraint->(\$tmp)"; - $accessor .= "or \$attribute->verify_type_constraint_error(\$name, \$tmp, \$constraint);\n"; + $accessor .= " || \$attribute->verify_type_constraint_error(\$name, \$tmp, \$constraint);\n"; $accessor .= "$slot = \$tmp;\n"; } else{ @@ -184,3 +187,4 @@ sub _generate_delegation{ 1; +__END__