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'}) {
-use Test::More tests => 35;
+use Test::More tests => 36;
use strict;
use warnings;
use lib 't/lib';
is(SuperInheritedGroups->basefield, 'base');
is(BaseInheritedGroups->undefined, undef);
+
+# make sure run-time @ISA changes trigger an inheritance chain recalculation
+SuperInheritedGroups->basefield(undef);
+BaseInheritedGroups->basefield('your base');
+
+# dirty hack, emulate Class::C3::Componentised
+require ExtraInheritedGroups;
+unshift @SuperInheritedGroups::ISA, qw/ExtraInheritedGroups/;
+
+# this comes from ExtraInheritedGroups
+is(SuperInheritedGroups->basefield, 'your extra base!');
--- /dev/null
+package ExtraInheritedGroups;
+use strict;
+use warnings;
+use base 'Class::Accessor::Grouped';
+
+__PACKAGE__->mk_group_accessors('inherited', 'basefield');
+__PACKAGE__->set_inherited (basefield => 'your extra base!');
+
+1;