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.
$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