From: Yuval Kogman Date: Sat, 23 May 2009 21:13:00 +0000 (+0200) Subject: Only use subname on __ANON__ code refs X-Git-Tag: 0.85~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0c858be68465df0e37946f7f5ee7392b865bad8a;p=gitmo%2FClass-MOP.git Only use subname on __ANON__ code refs --- diff --git a/Changes b/Changes index d1076d5..7dfafbc 100644 --- a/Changes +++ b/Changes @@ -14,6 +14,8 @@ Revision history for Perl extension Class-MOP. * Class::MOP::Class - Add direct_subclasses method (Sartak) - Tests for subclasses and direct_subclasses (Sartak) + - subname is no longer used unconditionally in add_method, but only if + the code reference's name is '__ANON__' (nothingmuch) 0.84 Tue, May 12, 2009 * Makefile.PL diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index a331ea4..bdc2793 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -619,10 +619,16 @@ sub add_method { # method. This is hackier, but quicker too. $self->{methods}{$method_name} = $method; - my $full_method_name = ($self->name . '::' . $method_name); + my ( $current_package, $current_name ) = Class::MOP::get_code_info($body); + + if ( $current_name eq '__ANON__' ) { + my $full_method_name = ($self->name . '::' . $method_name); + subname($full_method_name => $body); + } + $self->add_package_symbol( - { sigil => '&', type => 'CODE', name => $method_name }, - subname($full_method_name => $body) + { sigil => '&', type => 'CODE', name => $method_name }, + $body, ); }