use slow path for role create_class_with_roles under custom accessor generator
Matt S Trout [Thu, 3 May 2012 19:25:56 +0000 (19:25 +0000)]
lib/Moo/Role.pm

index fb82079..d84a5fd 100644 (file)
@@ -106,6 +106,15 @@ sub create_class_with_roles {
 
   $me->_inhale_if_moose($_) for @roles;
 
+  my $m;
+  if ($m = Moo->_accessor_maker_for($superclass)
+      and ref($m) ne 'Method::Generate::Accessor') {
+    # old fashioned way time.
+    *{_getglob("${new_name}::ISA")} = [ $superclass ];
+    $me->apply_roles_to_package($new_name, @roles);
+    return $new_name;
+  }
+
   require Sub::Quote;
 
   $me->SUPER::create_class_with_roles($superclass, @roles);