We only need local $? if we inline calls to DEMOLISH
[gitmo/Moose.git] / lib / Moose / Meta / Method / Destructor.pm
index 2ce956d..e06a13d 100644 (file)
@@ -28,6 +28,7 @@ sub new {
         'name'                 => $options{name},
         # ...
         'options'              => $options{options},
+        'definition_context'   => $options{definition_context},
         'associated_metaclass' => $options{metaclass},
     } => $class;
 
@@ -80,7 +81,6 @@ sub _initialize_body {
             'my $self = shift;',
             'return ' . $self->_generate_fallback_destructor('$self'),
                 'if Scalar::Util::blessed($self) ne \'' . $class . '\';',
-            'local $?;',
             $self->_generate_DEMOLISHALL('$self'),
             'return;',
         '}',
@@ -117,6 +117,7 @@ sub _generate_DEMOLISHALL {
     return unless @methods;
 
     return (
+        'local $?;',
         'my $igd = Devel::GlobalDestruction::in_global_destruction;',
         'Try::Tiny::try {',
             (map { $inv . '->' . $_->{class} . '::DEMOLISH($igd);' } @methods),
@@ -138,16 +139,16 @@ __END__
 
 =head1 DESCRIPTION
 
-This class is a subclass of L<Class::MOP::Class::Generated> that
+This class is a subclass of L<Class::MOP::Method::Inlined> that
 provides Moose-specific functionality for inlining destructors.
 
 To understand this class, you should read the the
-L<Class::MOP::Class::Generated> documentation as well.
+L<Class::MOP::Method::Inlined> documentation as well.
 
 =head1 INHERITANCE
 
 C<Moose::Meta::Method::Destructor> is a subclass of
-L<Moose::Meta::Method> I<and> L<Class::MOP::Method::Generated>.
+L<Moose::Meta::Method> I<and> L<Class::MOP::Method::Inlined>.
 
 =head1 METHODS