Fix unified generation
gfx [Sat, 15 Aug 2009 11:04:06 +0000 (20:04 +0900)]
lib/Class/MOP/Attribute.pm
lib/Class/MOP/Method/Accessor.pm

index 40bcf28..7f00c5a 100644 (file)
@@ -356,15 +356,19 @@ sub _process_accessors {
         $method_ctx = { %$ctx };
     }
 
+    my $metaclass = $self->associated_class;
+
     if (ref($accessor)) {
         (ref($accessor) eq 'HASH')
             || confess "bad accessor/reader/writer/predicate/clearer format, must be a HASH ref";
         my ($name, $method) = %{$accessor};
+
         $method = $self->accessor_metaclass->wrap(
-            $method,
-            package_name => $self->associated_class->name,
-            name         => $name,
-            definition_context => $method_ctx,
+            body                 => $method,
+            associated_metaclass => $metaclass,
+            package_name         => $metaclass->name,
+            name                 => $name,
+            definition_context   => $method_ctx,
         );
         $self->associate_method($method);
         return ($name, $method);
@@ -382,11 +386,12 @@ sub _process_accessors {
             }
 
             $method = $self->accessor_metaclass->new(
-                attribute     => $self,
-                accessor_type => $type,
-                package_name  => $self->associated_class->name,
-                name          => $accessor,
-                definition_context => $method_ctx,
+                attribute            => $self,
+                accessor_type        => $type,
+                associated_metaclass => $metaclass,
+                package_name         => $metaclass->name,
+                name                 => $accessor,
+                definition_context   => $method_ctx,
             );
         };
         confess "Could not create the '$type' method for " . $self->name . " because : $@" if $@;
index 395fd59..8a9ee8c 100644 (file)
@@ -35,6 +35,7 @@ sub new {
     # a cycle in the code, if not
     # needed
     weaken($self->{'attribute'});
+    weaken($self->{'associated_metaclass'});
 
     $self->_initialize_body;
 
@@ -58,8 +59,7 @@ sub _new {
         original_method      => $params->{original_method},
 
         # inherit from Class::MOP::Generated
-        is_inline            => ($params->{associated_metaclass}
-                                && $params->{associated_metaclass}->instance_metaclass->is_inlinable),
+        is_inline            => $params->{associated_metaclass}->instance_metaclass->is_inlinable,
         definition_context   => $params->{definition_context},
 
         # defined in this class