DESTROY is overridden by __PACKAGE__->meta->make_immutable.
Test case attached -- also test case exists in Moose repository,
as I originally thought this to be a Moose bug.
It is a regression from previous versions.
This bug was noticed in KiokuDB (KiokuDB::LiveObjects::Scope).
Using DEMOLISH or not making the class immutable does cause kiokudb's
test to pass.
Subject: | fail.t |
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 1;
BEGIN {
package FooBar;
use Moose;
has 'name' => (is => 'ro');
sub DESTROY { shift->name }
__PACKAGE__->meta->make_immutable;
}
my $f = FooBar->new(name => "SUSAN");
is($f->DESTROY, "SUSAN", "Did moose overload DESTROY?");