remove the metacircularity hack since this breaks things by destroying the assertion... attic/metacircularity_fixes
Matt S Trout [Mon, 20 Apr 2009 16:49:21 +0000 (17:49 +0100)]
lib/Class/MOP.pm
lib/Class/MOP/Class/Immutable/Trait.pm
t/000_load.t

index 315f25c..386495c 100644 (file)
@@ -676,7 +676,7 @@ undef Class::MOP::Instance->meta->{_package_cache_flag};
 Class::MOP::Class->meta->immutable_metaclass;
 $Class::MOP::Class::immutable_metaclass_cache{"Class::MOP::Class"}{"Class::MOP::Class::Immutable::Trait"} = Class::MOP::Class::Immutable::Class::MOP::Class->meta;
 
-$_->meta->make_immutable(
+Class::MOP::Class->initialize($_)->make_immutable(
     inline_constructor  => 1,
     replace_constructor => 1,
     constructor_name    => "_new",
index fa6448e..c2dcea8 100644 (file)
@@ -8,29 +8,6 @@ use MRO::Compat;
 use Carp 'confess';
 use Scalar::Util 'blessed', 'weaken';
 
-sub meta {
-    my $self = shift;
-
-    # if it is not blessed, then someone is asking
-    # for the meta of Class::MOP::Class:;Immutable::Trait
-    return Class::MOP::Class->initialize($self) unless blessed($self);
-
-    # otherwise, they are asking for the metaclass
-    # which has been made immutable, which is itself
-    # except in the cases where it is a metaclass itself
-    # that has been made immutable and for that we need
-    # to dig a bit ...
-
-    if ( $self->isa('Class::MOP::Class') ) {
-
-        # except this is a lie... oh well
-        return Class::MOP::class_of( $self->get_mutable_metaclass_name );
-    }
-    else {
-        return $self;
-    }
-}
-
 # the original class of the metaclass instance
 sub get_mutable_metaclass_name { $_[0]{__immutable}{original_class} }
 
index 682f17c..9b377c9 100644 (file)
@@ -37,7 +37,7 @@ my %METAS = (
     'Class::MOP::Method::Wrapped' => Class::MOP::Method::Wrapped->meta,
     'Class::MOP::Instance'        => Class::MOP::Instance->meta,
     'Class::MOP::Object'          => Class::MOP::Object->meta,
-    'Class::MOP::Class::Immutable::Trait' => Class::MOP::Class::Immutable::Trait->meta,
+    'Class::MOP::Class::Immutable::Trait' => Class::MOP::Class->initialize('Class::MOP::Class::Immutable::Trait'),
     'Class::MOP::Class::Immutable::Class::MOP::Class' => Class::MOP::Class::Immutable::Class::MOP::Class->meta,
 );
 
@@ -61,7 +61,7 @@ is_deeply(
         Class::MOP::Attribute->meta,
         Class::MOP::Class->meta,
         Class::MOP::Class::Immutable::Class::MOP::Class->meta,
-        Class::MOP::Class::Immutable::Trait->meta,
+        Class::MOP::Class->initialize('Class::MOP::Class::Immutable::Trait'),
         Class::MOP::Instance->meta,
         Class::MOP::Method->meta,
         Class::MOP::Method::Accessor->meta,