From: Matt S Trout Date: Mon, 20 Apr 2009 16:49:21 +0000 (+0100) Subject: remove the metacircularity hack since this breaks things by destroying the assertion... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fattic%2Fmetacircularity_fixes;p=gitmo%2FClass-MOP.git remove the metacircularity hack since this breaks things by destroying the assertion that $class->meta is Class::MOP::Class->initialize($class) --- diff --git a/lib/Class/MOP.pm b/lib/Class/MOP.pm index 315f25c..386495c 100644 --- a/lib/Class/MOP.pm +++ b/lib/Class/MOP.pm @@ -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", diff --git a/lib/Class/MOP/Class/Immutable/Trait.pm b/lib/Class/MOP/Class/Immutable/Trait.pm index fa6448e..c2dcea8 100644 --- a/lib/Class/MOP/Class/Immutable/Trait.pm +++ b/lib/Class/MOP/Class/Immutable/Trait.pm @@ -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} } diff --git a/t/000_load.t b/t/000_load.t index 682f17c..9b377c9 100644 --- a/t/000_load.t +++ b/t/000_load.t @@ -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,