From: Matt S Trout Date: Tue, 17 Jul 2012 12:18:21 +0000 (+0000) Subject: clear method cache after metaclass generation to fix autoclean bug X-Git-Tag: v1.000000~10 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c85a5738ea2a6f7de9ab1caf31fbf365c1c1e771;p=gitmo%2FMoo.git clear method cache after metaclass generation to fix autoclean bug --- diff --git a/Changes b/Changes index 37aba75..8018c78 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,5 @@ + - clear method cache after metaclass generation to fix autoclean bug + 0.091014 - 2012-07-16 - load overload.pm explicitly for overload::StrVal diff --git a/lib/Moo/HandleMoose.pm b/lib/Moo/HandleMoose.pm index 2de0c7b..fb68afd 100644 --- a/lib/Moo/HandleMoose.pm +++ b/lib/Moo/HandleMoose.pm @@ -65,6 +65,14 @@ sub inject_real_metaclass_for { }; my %methods = %{Role::Tiny->_concrete_methods_of($name)}; + + # if stuff gets added afterwards, _maybe_reset_handlemoose should + # trigger the recreation of the metaclass but we need to ensure the + # Role::Tiny cache is cleared so we don't confuse Moo itself. + if (my $info = $Role::Tiny::INFO{$name}) { + delete $info->{methods}; + } + # needed to ensure the method body is stable and get things named Sub::Defer::undefer_sub($_) for grep defined, values %methods; my @attrs;