X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FClass%2FMOP%2FMethod%2FInlined.pm;h=e9b9fba7ed30ca7267982b0f6f3ba19dad2209cc;hb=53362bcb1b32d87630190fbf50679dc37bb51adf;hp=7452e33849c261526d2629a318611ce0c52a5bfd;hpb=af72687d6d45c59be325b4d43c852606c8a2c9c1;p=gitmo%2FClass-MOP.git diff --git a/lib/Class/MOP/Method/Inlined.pm b/lib/Class/MOP/Method/Inlined.pm index 7452e33..e9b9fba 100644 --- a/lib/Class/MOP/Method/Inlined.pm +++ b/lib/Class/MOP/Method/Inlined.pm @@ -6,14 +6,12 @@ use warnings; use Carp 'confess'; use Scalar::Util 'blessed', 'weaken', 'looks_like_number', 'refaddr'; -our $VERSION = '0.85'; +our $VERSION = '1.11'; $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; use base 'Class::MOP::Method::Generated'; -sub _expected_method_class { $_[0]{_expected_method_class} } - sub _uninlined_body { my $self = shift; @@ -34,6 +32,22 @@ sub can_be_inlined { my $metaclass = $self->associated_metaclass; my $class = $metaclass->name; + # If we don't find an inherited method, this is a rather weird + # case where we have no method in the inheritance chain even + # though we're expecting one to be there + my $inherited_method + = $metaclass->find_next_method_by_name( $self->name ); + + if ( $inherited_method + && $inherited_method->isa('Class::MOP::Method::Wrapped') ) { + warn "Not inlining '" + . $self->name + . "' for $class since it " + . "has method modifiers which would be lost if it were inlined\n"; + + return 0; + } + my $expected_class = $self->_expected_method_class or return 1; @@ -58,19 +72,11 @@ sub can_be_inlined { return 1 if refaddr($expected_method) == refaddr($actual_method); - # If we don't find an inherited method, this is a rather weird - # case where we have no method in the inheritance chain even - # though we're expecting one to be there - # - # this returns 1 for backwards compatibility for now - my $inherited_method - = $metaclass->find_next_method_by_name( $self->name ) - or return 1; - # otherwise we have to check that the actual method is an inlined # version of what we're expecting if ( $inherited_method->isa(__PACKAGE__) ) { - if ( refaddr( $inherited_method->_uninlined_body ) + if ( $inherited_method->_uninlined_body + && refaddr( $inherited_method->_uninlined_body ) == refaddr($expected_method) ) { return 1; } @@ -96,12 +102,6 @@ sub can_be_inlined { . " call to $class->meta->make_immutable\n"; } - $warning - .= " ('" - . $self->name - . "' has method modifiers which would be lost if it were inlined)\n" - if $inherited_method->isa('Class::MOP::Method::Wrapped'); - warn $warning; return 0; @@ -141,7 +141,7 @@ Stevan Little Estevan@iinteractive.comE =head1 COPYRIGHT AND LICENSE -Copyright 2006-2009 by Infinity Interactive, Inc. +Copyright 2006-2010 by Infinity Interactive, Inc. L