From: gfx Date: Thu, 8 Oct 2009 11:48:21 +0000 (+0900) Subject: A tweak for backward compatibility X-Git-Tag: 0.37_04~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b6331c0cb8e40e1fad864408b9df967813036a6c;p=gitmo%2FMouse.git A tweak for backward compatibility --- diff --git a/lib/Mouse/Meta/Method/Accessor.pm b/lib/Mouse/Meta/Method/Accessor.pm index 9c5b746..c5faa54 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{