my ( $super_meta ) = @_;
if ($self->_can_fix_class_metaclass_incompatibility_by_subclassing($super_meta)) {
- $super_meta->meta->rebless_instance($self);
+ my $super_meta_name = $super_meta->is_immutable
+ ? $super_meta->_get_mutable_metaclass_name
+ : blessed($super_meta);
+ $super_meta_name->meta->rebless_instance($self);
}
}
"can't switch out the attribute metaclass of a class that already has attributes";
}
+# immutability...
+
+{
+ my $foometa = Foo::Meta::Class->create(
+ 'Foo::Immutable',
+ );
+ $foometa->make_immutable;
+ my $barmeta = Class::MOP::Class->create(
+ 'Bar::Mutable',
+ );
+ my $bazmeta = Class::MOP::Class->create(
+ 'Baz::Mutable',
+ );
+ $bazmeta->superclasses($foometa->name);
+ lives_ok { $bazmeta->superclasses($barmeta->name) }
+ "can still set superclasses";
+ ok(!$bazmeta->is_immutable,
+ "immutable superclass doesn't make this class immutable");
+ lives_ok { $bazmeta->make_immutable } "can still make immutable";
+}
+
done_testing;