From: Tomohiro Hosaka Date: Thu, 13 Jun 2013 18:52:08 +0000 (-0400) Subject: fix FOREIGNBUILDARGS not being called when no attributes created X-Git-Tag: v1.003000~57 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=85de1ef9dedd1a60115e475036dabaed68dc6ae2;p=gitmo%2FMoo.git fix FOREIGNBUILDARGS not being called when no attributes created --- diff --git a/lib/Moo.pm b/lib/Moo.pm index 388cbba..6899253 100644 --- a/lib/Moo.pm +++ b/lib/Moo.pm @@ -93,6 +93,9 @@ sub _set_superclasses { Moo->_constructor_maker_for($target) ->register_attribute_specs(%{$old->all_attribute_specs}); } + elsif (!$target->isa('Moo::Object')) { + Moo->_constructor_maker_for($target); + } no warnings 'once'; # piss off. -- mst $Moo::HandleMoose::MOUSE{$target} = [ grep defined, map Mouse::Util::find_meta($_), @_ diff --git a/t/foreignbuildargs.t b/t/foreignbuildargs.t index 291bd57..c5ef28e 100644 --- a/t/foreignbuildargs.t +++ b/t/foreignbuildargs.t @@ -23,11 +23,21 @@ use Test::More; my ($class, %args) = @_; return $args{attr}; } + + package t::ext_non_moo_strict::without_attr; + use Moo; + extends qw( t::non_moo_strict ); + + sub FOREIGNBUILDARGS { + my ($class, %args) = @_; + return $args{attr2}; + } } my $non_moo = t::non_moo_strict->new( 'bar' ); my $ext_non_moo = t::ext_non_moo_strict::with_attr->new( attr => 'bar', attr2 => 'baz' ); +my $ext_non_moo2 = t::ext_non_moo_strict::without_attr->new( attr => 'bar', attr2 => 'baz' ); is $non_moo->attr, 'bar', "non-moo accepts params"; @@ -35,6 +45,8 @@ is $ext_non_moo->attr, 'bar', "extended non-moo passes params"; is $ext_non_moo->attr2, 'baz', "extended non-moo has own attributes"; +is $ext_non_moo2->attr, 'baz', + "extended non-moo passes params"; done_testing;