1 package Class::MOP::Method::Inlined;
7 use Scalar::Util 'blessed', 'weaken', 'looks_like_number', 'refaddr';
9 our $VERSION = '0.82_01';
10 $VERSION = eval $VERSION;
11 our $AUTHORITY = 'cpan:STEVAN';
13 use base 'Class::MOP::Method::Generated';
15 sub _expected_method_class { $_[0]{_expected_method_class} }
21 = $self->associated_metaclass->find_next_method_by_name( $self->name )
24 if ( $super_method->isa(__PACKAGE__) ) {
25 return $super_method->_uninlined_body;
28 return $super_method->body;
34 my $metaclass = $self->associated_metaclass;
35 my $class = $metaclass->name;
37 my $expected_class = $self->_expected_method_class
40 # if we are shadowing a method we first verify that it is
41 # compatible with the definition we are replacing it with
42 my $expected_method = $expected_class->can( $self->name );
44 my $actual_method = $class->can( $self->name )
47 # the method is what we wanted (probably Moose::Object::new)
49 if refaddr($expected_method) == refaddr($actual_method);
51 # If we don't find an inherited method, this is a rather weird
52 # case where we have no method in the inheritance chain even
53 # though we're expecting one to be there
55 # this returns 1 for backwards compatibility for now
57 = $metaclass->find_next_method_by_name( $self->name )
60 # otherwise we have to check that the actual method is an inlined
61 # version of what we're expecting
62 if ( $inherited_method->isa(__PACKAGE__) ) {
63 if ( refaddr( $inherited_method->_uninlined_body )
64 == refaddr($expected_method) ) {
68 elsif ( refaddr( $inherited_method->body )
69 == refaddr($expected_method) ) {
76 . "' for $class since it is not"
77 . " inheriting the default ${expected_class}::"
80 if ( $self->isa("Class::MOP::Method::Constructor") ) {
82 # FIXME kludge, refactor warning generation to a method
84 .= "If you are certain you don't need to inline your"
85 . " constructor, specify inline_constructor => 0 in your"
86 . " call to $class->meta->make_immutable\n";
92 . "' has method modifiers which would be lost if it were inlined)\n"
93 if $inherited_method->isa('Class::MOP::Method::Wrapped');