weaken properly on reinitialize
Jesse Luehrs [Fri, 1 Oct 2010 04:46:12 +0000 (23:46 -0500)]
lib/Class/MOP/Class.pm

index 6199b49..38b11f9 100644 (file)
@@ -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;