From: Jesse Luehrs Date: Sat, 19 Sep 2009 20:21:41 +0000 (-0500) Subject: fix moose-nonmoose-moose metaclass compat stuff X-Git-Tag: 0.92~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=57a216235078da9b6ba291a0eb14d2eed86fec60;p=gitmo%2FMoose.git fix moose-nonmoose-moose metaclass compat stuff --- diff --git a/Changes b/Changes index e0b619c..7097888 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,10 @@ Also see Moose::Manual::Delta for more details of, and workarounds for, noteworthy changes. + * Moose::Meta::Class + - Metaclass compat fixing should already happen recursively, there's no + need to explicitly walk up the inheritance tree. (doy) + 0.91 Thu, Sep 17, 2009 * Moose::Object - Don't import any functions, in order to avoid polluting our namespace diff --git a/lib/Moose/Meta/Class.pm b/lib/Moose/Meta/Class.pm index cbd8ff9..f4b854f 100644 --- a/lib/Moose/Meta/Class.pm +++ b/lib/Moose/Meta/Class.pm @@ -296,29 +296,8 @@ sub _find_next_method_by_name_which_is_not_overridden { sub _fix_metaclass_incompatibility { my ($self, @superclasses) = @_; - foreach my $super (@superclasses) { - my $meta = Class::MOP::Class->initialize($super); - - my @all_supers = $meta->linearized_isa; - shift @all_supers; - - my @super_metas_to_fix = ($meta); - - # We need to check & fix the immediate superclass. If its @ISA - # contains a class without a metaclass instance, followed by a - # class _with_ a metaclass instance, init a metaclass instance - # for classes without one and fix compat up to and including - # the class which was already initialized. - my $idx = first_index { Class::MOP::class_of($_) } @all_supers; - - push @super_metas_to_fix, - map { Class::MOP::Class->initialize($_) } @all_supers[ 0 .. $idx ] - if $idx >= 0; - - foreach my $super_meta (@super_metas_to_fix) { - $self->_fix_one_incompatible_metaclass($super_meta); - } - } + $self->_fix_one_incompatible_metaclass($_) + for map { Moose::Meta::Class->initialize($_) } @superclasses; } sub _fix_one_incompatible_metaclass { diff --git a/t/600_todo_tests/006_moose_nonmoose_metatrait_init_order.t b/t/050_metaclasses/040_moose_nonmoose_metatrait_init_order.t similarity index 75% rename from t/600_todo_tests/006_moose_nonmoose_metatrait_init_order.t rename to t/050_metaclasses/040_moose_nonmoose_metatrait_init_order.t index 1e6c166..bfca0aa 100644 --- a/t/600_todo_tests/006_moose_nonmoose_metatrait_init_order.t +++ b/t/050_metaclasses/040_moose_nonmoose_metatrait_init_order.t @@ -24,8 +24,5 @@ my $subsubclass_meta = Moose->init_meta( for_class => 'SubSubClassUseBase' ); ok does_role($subsubclass_meta, 'My::Role'), 'SubSubClass metaclass does role from grandparent metaclass'; my $subclass_meta = find_meta('SubClassUseBase'); -TODO: { - local $TODO = "In-between class' metaclass does not do My::Role"; - ok does_role($subclass_meta, 'My::Role'), - 'SubClass metaclass does role from parent metaclass'; -} +ok does_role($subclass_meta, 'My::Role'), + 'SubClass metaclass does role from parent metaclass'; diff --git a/t/600_todo_tests/007_moose_nonmoose_moose_chain_init_meta.t b/t/050_metaclasses/041_moose_nonmoose_moose_chain_init_meta.t similarity index 53% rename from t/600_todo_tests/007_moose_nonmoose_moose_chain_init_meta.t rename to t/050_metaclasses/041_moose_nonmoose_moose_chain_init_meta.t index a91f20e..674b825 100644 --- a/t/600_todo_tests/007_moose_nonmoose_moose_chain_init_meta.t +++ b/t/050_metaclasses/041_moose_nonmoose_moose_chain_init_meta.t @@ -17,11 +17,6 @@ use warnings; use Test::More tests => 1; use Test::Exception; -TODO: { - local $TODO = 'Metaclass incompatibility'; - - lives_ok { - Moose->init_meta(for_class => 'SomeClass'); - } 'Moose class => use base => Moose Class, then Moose->init_meta on middle class ok'; -} - +lives_ok { + Moose->init_meta(for_class => 'SomeClass'); +} 'Moose class => use base => Moose Class, then Moose->init_meta on middle class ok';