From: Jesse Luehrs Date: Thu, 11 Nov 2010 17:00:11 +0000 (-0600) Subject: actually, cmop should be handling initializers here too X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=398a82df319a28b66dfd22e98c87a0adfb12c83f;p=gitmo%2FClass-MOP.git actually, cmop should be handling initializers here too --- diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index cfa11fe..26d4bda 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -681,9 +681,18 @@ sub _inline_init_attr_from_constructor { my $self = shift; my ($attr, $idx) = @_; - return $attr->_inline_set_value( - '$instance', '$params->{\'' . $attr->init_arg . '\'}' - ), + my @initial_value = $attr->_inline_set_value( + '$instance', '$params->{\'' . $attr->init_arg . '\'}', + ); + + push @initial_value, ( + '$attrs->[' . $idx . ']->set_initial_value(', + '$instance,', + $attr->_inline_instance_get('$instance'), + ');', + ) if $attr->has_initializer; + + return @initial_value; } sub _inline_init_attr_from_default { @@ -693,7 +702,16 @@ sub _inline_init_attr_from_default { my $default = $self->_inline_default_value($attr, $idx); return unless $default; - return $attr->_inline_set_value('$instance', $default); + my @initial_value = $attr->_inline_set_value('$instance', $default); + + push @initial_value, ( + '$attrs->[' . $idx . ']->set_initial_value(', + '$instance,', + $attr->_inline_instance_get('$instance'), + ');', + ) if $attr->has_initializer; + + return @initial_value; } sub _inline_default_value {