From: Matt S Trout Date: Sun, 10 Jun 2007 18:01:13 +0000 (+0000) Subject: fix inline constructor for hierarchy with multiple BUILD methods X-Git-Tag: 0_23~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=73b84d2efeee418a5491b8f4338b28813c0dca65;p=gitmo%2FMoose.git fix inline constructor for hierarchy with multiple BUILD methods --- diff --git a/Changes b/Changes index 3e3eec6..a0b9508 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,8 @@ Revision history for Perl extension Moose 0.23 + * Moose::Meta::Method::Constructor + - fix inlined constructor for hierarchy with multiple BUILD methods (mst) * Moose::Meta::Class - Modify make_immutable to work with the new Class::MOP immutable mechanism + POD + very basic test (groditi) diff --git a/lib/Moose/Meta/Method/Constructor.pm b/lib/Moose/Meta/Method/Constructor.pm index c82ec6c..4553078 100644 --- a/lib/Moose/Meta/Method/Constructor.pm +++ b/lib/Moose/Meta/Method/Constructor.pm @@ -98,7 +98,7 @@ sub _generate_BUILDALL { foreach my $method (reverse $self->associated_metaclass->find_all_methods_by_name('BUILD')) { push @BUILD_calls => '$instance->' . $method->{class} . '::BUILD(\%params)'; } - return join "\n" => @BUILD_calls; + return join ";\n" => @BUILD_calls; } sub _generate_slot_initializer { diff --git a/t/300_immutable_moose.t b/t/300_immutable_moose.t index 2450f5d..f057976 100644 --- a/t/300_immutable_moose.t +++ b/t/300_immutable_moose.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 6; +use Test::More tests => 8; use Test::Exception; BEGIN { @@ -31,6 +31,30 @@ BEGIN { lives_ok{ $meta->add_role($foo_role) } "Add Role is unlocked"; } +{ + package Bar; + + use Moose; + + sub BUILD { 'bar' } +} + +{ + package Baz; + + use Moose; + + extends 'Bar'; + + sub BUILD { 'baz' } +} + +lives_ok { Bar->meta->make_immutable } + 'Immutable meta with single BUILD'; + +lives_ok { Baz->meta->make_immutable } + 'Immutable meta with multiple BUILDs'; + =pod Nothing here yet, but soon :)