From: gfx Date: Tue, 13 Oct 2009 07:38:21 +0000 (+0900) Subject: Fix RT #50422 X-Git-Tag: 0.39~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c6e5eee14b916e727dd973cb19f943eb32a2e28e;p=gitmo%2FMouse.git Fix RT #50422 --- diff --git a/lib/Mouse/Meta/Method/Destructor.pm b/lib/Mouse/Meta/Method/Destructor.pm index 60cc49e..a2941b3 100644 --- a/lib/Mouse/Meta/Method/Destructor.pm +++ b/lib/Mouse/Meta/Method/Destructor.pm @@ -13,6 +13,7 @@ sub _generate_destructor{ my $demolishall = ''; for my $class ($metaclass->linearized_isa) { no strict 'refs'; + no warnings 'once'; if (*{$class . '::DEMOLISH'}{CODE}) { $demolishall .= "${class}::DEMOLISH(\$self);\n"; } diff --git a/lib/Mouse/Meta/Module.pm b/lib/Mouse/Meta/Module.pm index 9ba54f6..15583d9 100755 --- a/lib/Mouse/Meta/Module.pm +++ b/lib/Mouse/Meta/Module.pm @@ -91,7 +91,7 @@ sub add_method { my $pkg = $self->name; no strict 'refs'; - no warnings 'redefine'; + no warnings 'redefine', 'once'; *{ $pkg . '::' . $name } = $code; } @@ -118,6 +118,7 @@ sub has_method { my $code = do{ no strict 'refs'; + no warnings 'once'; *{ $self->{package} . '::' . $method_name }{CODE}; }; @@ -131,7 +132,11 @@ sub get_method_body{ or $self->throw_error('You must define a method name'); return $self->{methods}{$method_name} ||= do{ - my $code = do{ no strict 'refs'; *{$self->{package} . '::' . $method_name}{CODE} }; + my $code = do{ + no strict 'refs'; + no warnings 'once'; + *{$self->{package} . '::' . $method_name}{CODE}; + }; ($code && $self->_code_is_mine($code)) ? $code : undef; }; diff --git a/lib/Mouse/Object.pm b/lib/Mouse/Object.pm index 20748e9..feef5cb 100644 --- a/lib/Mouse/Object.pm +++ b/lib/Mouse/Object.pm @@ -51,8 +51,11 @@ sub BUILDALL { return unless $self->can('BUILD'); for my $class (reverse $self->meta->linearized_isa) { - my $build = do{ no strict 'refs'; *{ $class . '::BUILD' }{CODE} } - or next; + my $build = do{ + no strict 'refs'; + no warnings 'once'; + *{ $class . '::BUILD' }{CODE}; + } or next; $self->$build(@_); } @@ -71,8 +74,11 @@ sub DEMOLISHALL { # that time (at least tests suggest so ;) foreach my $class (@{ Mouse::Util::get_linear_isa(ref $self) }) { - my $demolish = do{ no strict 'refs'; *{ $class . '::DEMOLISH'}{CODE} } - or next; + my $demolish = do{ + no strict 'refs'; + no warnings 'once'; + *{ $class . '::DEMOLISH'}{CODE}; + } or next; $self->$demolish(); }