Checking in changes prior to tagging of version 0.50_01. Changelog diff is:
[gitmo/Mouse.git] / lib / Mouse / Meta / Method / Constructor.pm
index c4f68fd..6064aff 100644 (file)
@@ -1,5 +1,5 @@
 package Mouse::Meta::Method::Constructor;
-use Mouse::Util qw(get_code_ref); # enables strict and warnings
+use Mouse::Util qw(:meta); # enables strict and warnings
 
 sub _inline_slot{
     my(undef, $self_var, $attr_name) = @_;
@@ -60,6 +60,7 @@ sub _generate_processattrs {
 
         my $init_arg        = $attr->init_arg;
         my $type_constraint = $attr->type_constraint;
+        my $is_weak_ref     = $attr->is_weak_ref;
         my $need_coercion;
 
         my $instance_slot  = $method_class->_inline_slot('$instance', $key);
@@ -76,9 +77,9 @@ sub _generate_processattrs {
         my $post_process = '';
         if(defined $type_constraint){
             $post_process .= "\$checks[$index]->($instance_slot)";
-            $post_process .= "  or $attr_var->verify_type_constraint_error(q{$key}, $instance_slot, $constraint_var);\n";
+            $post_process .= "  or $attr_var->_throw_type_constraint_error($instance_slot, $constraint_var);\n";
         }
-        if($attr->is_weak_ref){
+        if($is_weak_ref){
             $post_process .= "Scalar::Util::weaken($instance_slot) if ref $instance_slot;\n";
         }
 
@@ -126,6 +127,9 @@ sub _generate_processattrs {
                 }
 
                 $code .= "$instance_slot = $value;\n";
+                if($is_weak_ref){
+                    $code .= "Scalar::Util::weaken($instance_slot);\n";
+                }
             }
         }
         elsif ($attr->is_required) {
@@ -177,7 +181,7 @@ sub _generate_BUILDALL {
 
     my @code;
     for my $class ($metaclass->linearized_isa) {
-        if (get_code_ref($class, 'BUILD')) {
+        if (Mouse::Util::get_code_ref($class, 'BUILD')) {
             unshift  @code, qq{${class}::BUILD(\$instance, \$args);};
         }
     }
@@ -193,7 +197,7 @@ Mouse::Meta::Method::Constructor - A Mouse method generator for constructors
 
 =head1 VERSION
 
-This document describes Mouse version 0.40
+This document describes Mouse version 0.50_01
 
 =head1 SEE ALSO