Re: Not inlining 'new' for Foo since it has method modifiers which would be lost if it were inlined
[email protected] (Chris Prather)
| Newsgroups | perl.moose |
|---|---|
| Message-ID | <CAEFJ168CDFmdksEC6Hs=6V_EMMYnnYaQr6=Ni4jL4EXxiiEvOw@mail.gmail.com> |
On Fri, Feb 24, 2012 at 7:36 AM, Bill Moseley <[email protected]> wrote: > On Fri, Feb 24, 2012 at 6:59 PM, Chris Prather <[email protected]> wrote: > >> Throwable::Error composes leads to: >> >> >> https://metacpan.org/source/RJBS/Throwable-0.102080/lib/StackTrace/Auto.pm#L71 >> >> In which we find 'around new => { ... }'. Which is exactly the method >> modifier that Moose is warning about. >> > > Thanks Chris. Is the solution to not make_immutable all the classes that > inherit from Throwable::Error then or to also use inline_constructor => 1 > then? inline_constructor => 0 > I guess I'm not sure why the method modifier would be lost, but that's just > my lack of understand of how Moose works. ;) If I understand it properly, the inlined constructor would be a different subroutine entry from the one being modified. If we draw it out a little (with package names changed to protect the innocent): package Parent; use Moose; # bring's in Moose::Object::new around new => { ... }; # replaces Moose::Object::new with "Parent::wrapped_new" package Child; use Moose; extends qw(Parent); # brings in "Parent::wrapped_new" __PACKAGE__->meta->make_immutable(); # tries to create a Child::new # ... but the wrapper is already applied as a part of Parent::wrapped_new # ... and so isn't going to be applied Does this help? -Chris