Subject: | During a rebless, triggers will fire for any attributes that have an undefined init_arg and began the rebless with a value. |
During a rebless, triggers will fire for any attributes that have an
undefined init_arg and began the rebless with a value.
Triggers shouldn't fire in this case. The value is simply being assumed
by the reblessed instance -- it isn't being set in an "interesting" way.
It looks to me like this will have been a bug since at least as far
back as 2.00.
=====
use Test::More;
{ package MyClass;
use Moose;
our $FIRINGS;
has foo => (
init_arg => undef,
is => 'rw',
isa => 'Any',
trigger => sub { $FIRINGS++ },
);
}
{ package MyClass::Extended;
use Moose;
extends 'MyClass';
}
TODO: {
local $TODO = 'bug demo';
my $obj = MyClass->new;
$obj->foo('FOO');
$MyClass::FIRINGS = 0;
MyClass::Extended->meta->rebless_instance($obj);
cmp_ok(MyClass::FIRINGS, '==', 0, 'trigger did NOT fire');
}
=====
The problem may lie in CMOP::Class::_fixup_attributes_after_rebless,
where such attributes are fixed up via set_value, which entails a
trigger call.