From: Jesse Luehrs Date: Fri, 1 Oct 2010 04:46:12 +0000 (-0500) Subject: weaken properly on reinitialize X-Git-Tag: 1.10~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=909e3015a59586952d9295d6b240c0e37caaa460;p=gitmo%2FClass-MOP.git weaken properly on reinitialize --- diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index 6199b49..38b11f9 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -53,9 +53,13 @@ sub reinitialize { my $old_metaclass = blessed($options{package}) ? $options{package} : Class::MOP::get_metaclass_by_name($options{package}); + $options{weaken} = Class::MOP::metaclass_is_weak($old_metaclass->name) + if !exists $options{weaken} + && blessed($old_metaclass) + && $old_metaclass->isa('Class::MOP::Class'); $old_metaclass->_remove_generated_metaobjects if $old_metaclass && $old_metaclass->isa('Class::MOP::Class'); - my $new_metaclass = $class->SUPER::reinitialize(@args); + my $new_metaclass = $class->SUPER::reinitialize(%options); $new_metaclass->_restore_metaobjects_from($old_metaclass) if $old_metaclass && $old_metaclass->isa('Class::MOP::Class'); return $new_metaclass;