We need to be smarter about recalculation of __cag_supers within inherited, as @ISA...
[p5sagit/Class-Accessor-Grouped.git] / lib / Class / Accessor / Grouped.pm
index bdba1a8..b983975 100644 (file)
@@ -303,8 +303,11 @@ sub get_inherited {
     no strict 'refs';
     return ${$class.'::__cag_'.$_[1]} if defined(${$class.'::__cag_'.$_[1]});
 
-    if (!@{$class.'::__cag_supers'}) {
+    # we need to be smarter about recalculation, as @ISA (thus supers) can very well change in-flight
+    my $pkg_gen = mro::get_pkg_gen ($class);
+    if (!@{$class.'::__cag_supers'} or ${$class.'::__cag_pkg_gen'} != $pkg_gen ) {
         @{$class.'::__cag_supers'} = $_[0]->get_super_paths;
+        ${$class.'::__cag_pkg_gen'} = $pkg_gen;
     };
 
     foreach (@{$class.'::__cag_supers'}) {