From: Dave Rolsky Date: Tue, 24 Aug 2010 14:36:32 +0000 (-0500) Subject: Fix a mysterious failure reported by Piers Cawley X-Git-Tag: 1.07~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0517ea60ecd1f0e3352f3e9709c3dbf3a092daf2;p=gitmo%2FClass-MOP.git Fix a mysterious failure reported by Piers Cawley Unfortunately, neither of us could think of a simple test for this, but Piers confirmed that the patch fixes the failure he saw in production. May be related to the use of MX::Declare and/or TryCatch. --- diff --git a/lib/Class/MOP/Mixin/HasMethods.pm b/lib/Class/MOP/Mixin/HasMethods.pm index 40dd03d..069e005 100644 --- a/lib/Class/MOP/Mixin/HasMethods.pm +++ b/lib/Class/MOP/Mixin/HasMethods.pm @@ -161,10 +161,11 @@ sub get_method_list { my $namespace = $self->namespace; - # Constants will show up as some sort of reference in the namespace hash - # ref. + # Constants may show up as some sort of reference in the namespace hash + # ref, depending on the Perl version. return grep { - ( ref $namespace->{$_} || *{ $namespace->{$_} }{CODE} ) + defined $namespace->{$_} + && ( ref $namespace->{$_} || *{ $namespace->{$_} }{CODE} ) && $self->has_method($_) } keys %{$namespace}; @@ -179,7 +180,11 @@ sub _get_local_methods { my $namespace = $self->namespace; return map { $self->get_method($_) } - grep { ref $namespace->{$_} || *{ $namespace->{$_} }{CODE} } + grep { + defined $namespace->{$_} + && ( ref $namespace->{$_} + || *{ $namespace->{$_} }{CODE} ) + } keys %{$namespace}; }