Subject: | Empty DESTROY causes problems |
<p>There is an empty DESTROY subroutine in Attribute::Handlers, which means you can't mix it into a class hierarchy with existing DESTROY methods. All the tests run without it - so I'm guessing it's an oversight?</p>
<p>Test file demonstrating the problem attached. Fix is (unless I'm missing something) removal of the DESTROY line.</p>
#! /usr/bin/perl
use strict;
use warnings;
use NEXT;
my %Called;
{
package Base;
sub new { bless [], shift};
sub DESTROY {
++$Called{+__PACKAGE__};
$_[0]->NEXT::DESTROY;
};
}
{
package Handler;
use base qw(Attribute::Handlers Base);
sub DESTROY {
++$Called{+__PACKAGE__};
$_[0]->NEXT::DESTROY;
};
}
# If we remove the DESTROY everything works
# undef *Attribute::Handlers::DESTROY;
{
my $o = Handler->new;
};
use Test::More tests => 3;
is scalar(keys %Called), 2, 'two destroy methods called';
is $Called{Base}, 1, 'Base destroy called';
is $Called{Handler}, 1, 'Handler destroy called';