From: Graham Knop Date: Sun, 4 Aug 2013 14:22:30 +0000 (-0400) Subject: ensure DemolishAll is loaded before global destruction for inflated classes X-Git-Tag: v1.003001~17 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMoo.git;a=commitdiff_plain;h=4de2328ff1cafef7b1446d472ae65f87e59d1040 ensure DemolishAll is loaded before global destruction for inflated classes Classes that use a combination of Moo and Moose can end up using Moose's constructor, but still inheriting from Moo::Object. This means means Moo::Object's DEMOLISHALL will still be used, but DemolishAll.pm may not be loaded until the object is destroyed. If this occurs in global destruction, a number of things don't work properly, including base.pm. Avoid this by ensuring DemolishAll is loaded on inflation of Moo classes. --- diff --git a/lib/Moo/HandleMoose.pm b/lib/Moo/HandleMoose.pm index 5c763e8..3d896f8 100644 --- a/lib/Moo/HandleMoose.pm +++ b/lib/Moo/HandleMoose.pm @@ -192,6 +192,10 @@ sub inject_real_metaclass_for { $meta->find_method_by_name('new'), 'Moo::HandleMoose::FakeConstructor', ); + # a combination of Moo and Moose may bypass a Moo constructor but still + # use a Moo DEMOLISHALL. We need to make sure this is loaded before + # global destruction. + require Method::Generate::DemolishAll; } $meta->add_role(Class::MOP::class_of($_)) for grep !/\|/ && $_ ne $name, # reject Foo|Bar and same-role-as-self