From: Dave Rolsky Date: Mon, 15 Jun 2009 15:24:54 +0000 (-0500) Subject: Revert caching of added methods, since that caused a bug. X-Git-Tag: 0.86~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f675e1296014dc971cdd2166a9a14c79bac8a5d6;p=gitmo%2FClass-MOP.git Revert caching of added methods, since that caused a bug. --- diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index 237023b..79168b5 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -619,11 +619,8 @@ sub add_method { $method->attach_to_class($self); - # This used to call get_method_map, which meant we would build all - # the method objects for the class just because we added one - # method. This is hackier, but quicker too. - $self->{methods}{$method_name} = $method; - + $self->get_method_map->{$method_name} = $method; + my ( $current_package, $current_name ) = Class::MOP::get_code_info($body); if ( $current_name eq '__ANON__' ) { @@ -719,7 +716,7 @@ sub has_method { (defined $method_name && $method_name) || confess "You must define a method name"; - exists $self->{methods}{$method_name} || exists $self->get_method_map->{$method_name}; + exists $self->get_method_map->{$method_name}; } sub get_method { @@ -727,7 +724,7 @@ sub get_method { (defined $method_name && $method_name) || confess "You must define a method name"; - return $self->{methods}{$method_name} || $self->get_method_map->{$method_name}; + return $self->get_method_map->{$method_name}; } sub remove_method { diff --git a/t/003_methods.t b/t/003_methods.t index d8b71d5..b1c97a7 100644 --- a/t/003_methods.t +++ b/t/003_methods.t @@ -258,7 +258,7 @@ is( $new_method->original_method, $method, '... the cloned method has the correc ); { - no warnings 'redefine'; + no warnings 'redefine', 'once'; *foo = sub { my $self = shift; $self->{custom_store} = $_[0];