X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FClass%2FMOP%2FImmutable.pm;h=e1f279aa95a911a4856cc46f8899d1999b450fa6;hb=e056bd4245c57e24563a47d918872731e77a5e73;hp=f4edaf56c5c1d33fa5bc70235c5b2a2bafdf0823;hpb=a6639567245e276edaf04dc202d77129ed2119a3;p=gitmo%2FClass-MOP.git diff --git a/lib/Class/MOP/Immutable.pm b/lib/Class/MOP/Immutable.pm index f4edaf5..e1f279a 100644 --- a/lib/Class/MOP/Immutable.pm +++ b/lib/Class/MOP/Immutable.pm @@ -9,7 +9,7 @@ use Class::MOP::Method::Constructor; use Carp 'confess'; use Scalar::Util 'blessed'; -our $VERSION = '0.78_01'; +our $VERSION = '0.81'; $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; @@ -97,11 +97,18 @@ sub _inline_constructor { return unless $self->options->{inline_constructor}; - return - unless $self->options->{replace_constructor} - or !$self->metaclass->has_method( - $self->options->{constructor_name} - ); + unless ($self->options->{replace_constructor} + or !$self->metaclass->has_method( + $self->options->{constructor_name} + )) { + my $class = $self->metaclass->name; + warn "Not inlining a constructor for $class since it defines" + . " its own constructor.\n" + . "If you are certain you don't need to inline your" + . " constructor, specify inline_constructor => 0 in your" + . " call to $class->meta->make_immutable\n"; + return; + } my $constructor_class = $self->options->{constructor_class}; @@ -169,7 +176,7 @@ my %DEFAULT_METHODS = ( # that has been made immutable and for that we need # to dig a bit ... if ($self->isa('Class::MOP::Class')) { - return $self->{'___original_class'}->meta; + return Class::MOP::class_of($self->{'___original_class'}); } else { return $self; @@ -184,7 +191,7 @@ sub _create_methods_for_immutable_metaclass { my $self = shift; my $metaclass = $self->metaclass; - my $meta = $metaclass->meta; + my $meta = Class::MOP::class_of($metaclass); return { %DEFAULT_METHODS, @@ -200,7 +207,7 @@ sub _create_methods_for_immutable_metaclass { sub _make_read_only_methods { my $self = shift; - my $metameta = $self->metaclass->meta; + my $metameta = Class::MOP::class_of($self->metaclass); my %methods; foreach my $read_only_method ( @{ $self->options->{read_only} } ) { @@ -238,7 +245,7 @@ sub _make_memoized_methods { my %methods; - my $metameta = $self->metaclass->meta; + my $metameta = Class::MOP::class_of($self->metaclass); my $memoized_methods = $self->options->{memoize}; foreach my $method_name ( keys %{$memoized_methods} ) { @@ -279,7 +286,7 @@ sub _make_wrapped_methods { my $wrapped_methods = $self->options->{wrapped}; - my $metameta = $self->metaclass->meta; + my $metameta = Class::MOP::class_of($self->metaclass); foreach my $method_name ( keys %{$wrapped_methods} ) { my $method = $metameta->find_method_by_name($method_name); @@ -383,10 +390,10 @@ Class::MOP::Immutable - A class to transform Class::MOP::Class metaclasses remove_package_symbol /], memoize => { - class_precedence_list => 'ARRAY', - compute_all_applicable_attributes => 'ARRAY', - get_meta_instance => 'SCALAR', - get_method_map => 'SCALAR', + class_precedence_list => 'ARRAY', + get_all_attributes => 'ARRAY', + get_meta_instance => 'SCALAR', + get_method_map => 'SCALAR', } });