dVAR;
MAGIC* const mg = mg_find((SV*)stash, PERL_MAGIC_overload_table);
AMT amt;
+ const struct mro_meta* stash_meta = HvMROMETA(stash);
U32 newgen;
- newgen = PL_sub_generation + HvMROMETA(stash)->cache_gen;
+ newgen = PL_sub_generation + stash_meta->pkg_gen + stash_meta->cache_gen;
if (mg) {
const AMT * const amtp = (AMT*)mg->mg_ptr;
if (amtp->was_ok_am == PL_amagic_generation
MAGIC *mg;
AMT *amtp;
U32 newgen;
+ struct mro_meta* stash_meta;
if (!stash || !HvNAME_get(stash))
return NULL;
- newgen = PL_sub_generation + HvMROMETA(stash)->cache_gen;
+ stash_meta = HvMROMETA(stash);
+ newgen = PL_sub_generation + stash_meta->pkg_gen + stash_meta->cache_gen;
mg = mg_find((SV*)stash, PERL_MAGIC_overload_table);
if (!mg) {
use strict;
use warnings;
-require q(./test.pl); plan(tests => 12);
+require q(./test.pl); plan(tests => 18);
{
package MRO_A;
# XXX TODO (when there's a way to backtrack through a glob's aliases)
# push(@MRO_M::ISA, 'MRO_TestOtherBase');
# is(eval { MRO_N->testfunctwo() }, 321);
+
+# Simple DESTROY Baseline
+{
+ my $x = 0;
+ my $obj;
+
+ {
+ package DESTROY_MRO_Baseline;
+ sub new { bless {} => shift }
+ sub DESTROY { $x++ }
+
+ package DESTROY_MRO_Baseline_Child;
+ our @ISA = qw/DESTROY_MRO_Baseline/;
+ }
+
+ $obj = DESTROY_MRO_Baseline->new();
+ undef $obj;
+ is($x, 1);
+
+ $obj = DESTROY_MRO_Baseline_Child->new();
+ undef $obj;
+ is($x, 2);
+}
+
+# Dynamic DESTROY
+{
+ my $x = 0;
+ my $obj;
+
+ {
+ package DESTROY_MRO_Dynamic;
+ sub new { bless {} => shift }
+
+ package DESTROY_MRO_Dynamic_Child;
+ our @ISA = qw/DESTROY_MRO_Dynamic/;
+ }
+
+ $obj = DESTROY_MRO_Dynamic->new();
+ undef $obj;
+ is($x, 0);
+
+ $obj = DESTROY_MRO_Dynamic_Child->new();
+ undef $obj;
+ is($x, 0);
+
+ no warnings 'once';
+ *DESTROY_MRO_Dynamic::DESTROY = sub { $x++ };
+
+ $obj = DESTROY_MRO_Dynamic->new();
+ undef $obj;
+ is($x, 1);
+
+ $obj = DESTROY_MRO_Dynamic_Child->new();
+ undef $obj;
+ is($x, 2);
+}