X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=lib%2FMouse%2FMeta%2FMethod%2FConstructor.pm;fp=lib%2FMouse%2FMeta%2FMethod%2FConstructor.pm;h=610e98ac6191279b352e5147fdc0b10c2ffcd1d9;hp=fe329391f14eb5cfb94f4a2d1a7047dc41edd797;hb=f1575d9f6d73252e751770a6c7ac717237059f29;hpb=7f627364a9120ef321d5903f33fb2522657817eb diff --git a/lib/Mouse/Meta/Method/Constructor.pm b/lib/Mouse/Meta/Method/Constructor.pm index fe32939..610e98a 100644 --- a/lib/Mouse/Meta/Method/Constructor.pm +++ b/lib/Mouse/Meta/Method/Constructor.pm @@ -87,10 +87,6 @@ sub _generate_initialize_object { $post_process .= "\$checks[$index]->($instance_slot)\n"; $post_process .= " or $attr_var->_throw_type_constraint_error($instance_slot, $constraint_var);\n"; } - if($is_weak_ref){ - $post_process = "Scalar::Util::weaken($instance_slot) " - . "if ref $instance_slot;\n"; - } # build cde for an attribute if (defined $init_arg) { @@ -151,6 +147,11 @@ sub _generate_initialize_object { $code .= "}\n" if defined $init_arg; + if($is_weak_ref){ + $code .= "Scalar::Util::weaken($instance_slot) " + . "if ref $instance_slot;\n"; + } + push @res, $code; }