move to early generation of DESTROY/DEMOLISHALL where possible and hope like hell...
[gitmo/Role-Tiny.git] / lib / Method / Generate / Constructor.pm
index e4f7b1f..11f0589 100644 (file)
@@ -60,6 +60,10 @@ sub generate_method {
     );
   }
   $body .= '    return $new;'."\n";
+  if ($into->can('DEMOLISH')) {
+    { local $@; require Method::Generate::DemolishAll; }
+    Method::Generate::DemolishAll->new->generate_method($into);
+  }
   quote_sub
     "${into}::${name}" => $body,
     $self->{captures}, $quote_opts||{}