[Moose-commits] r7209 - in Class-MOP/trunk: . lib/Class/MOP t
autarch at code2.0beta.co.uk
autarch at code2.0beta.co.uk
Wed Dec 31 16:23:50 GMT 2008
Author: autarch
Date: 2008-12-31 08:23:50 -0800 (Wed, 31 Dec 2008)
New Revision: 7209
Modified:
Class-MOP/trunk/Changes
Class-MOP/trunk/lib/Class/MOP/Class.pm
Class-MOP/trunk/t/073_make_mutable.t
Log:
Fix a bug where a class made immutable and then mutable would end up
sharing an immutable transformer with other classes, leading to
bizarro bugs later.
Modified: Class-MOP/trunk/Changes
===================================================================
--- Class-MOP/trunk/Changes 2008-12-31 16:07:42 UTC (rev 7208)
+++ Class-MOP/trunk/Changes 2008-12-31 16:23:50 UTC (rev 7209)
@@ -1,5 +1,12 @@
Revision history for Perl extension Class-MOP.
+0.75 Tue, December 31, 2008
+ * Class::MOP::Class
+ - A class that was made immutable and then mutable could end up
+ sharing an immutable transformer object
+ (Class::MOP::Immutable) with other classes, leading to all
+ sorts of odd bugs. Reported by t0m. (Dave Rolsky)
+
0.74 Tue, December 25, 2008
* MOP.xs
- Add an xs implementation of Class::MOP::is_class_loaded (closes
Modified: Class-MOP/trunk/lib/Class/MOP/Class.pm
===================================================================
--- Class-MOP/trunk/lib/Class/MOP/Class.pm 2008-12-31 16:07:42 UTC (rev 7208)
+++ Class-MOP/trunk/lib/Class/MOP/Class.pm 2008-12-31 16:23:50 UTC (rev 7209)
@@ -1055,8 +1055,7 @@
sub get_immutable_transformer {
my $self = shift;
if( $self->is_mutable ){
- my $class = ref $self || $self;
- return $IMMUTABLE_TRANSFORMERS{$class} ||= $self->create_immutable_transformer;
+ return $IMMUTABLE_TRANSFORMERS{$self->name} ||= $self->create_immutable_transformer;
}
confess "unable to find transformer for immutable class"
unless exists $IMMUTABLE_OPTIONS{$self->name};
Modified: Class-MOP/trunk/t/073_make_mutable.t
===================================================================
--- Class-MOP/trunk/t/073_make_mutable.t 2008-12-31 16:07:42 UTC (rev 7208)
+++ Class-MOP/trunk/t/073_make_mutable.t 2008-12-31 16:23:50 UTC (rev 7209)
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::More tests => 113;
+use Test::More tests => 114;
use Test::Exception;
use Scalar::Util;
@@ -228,3 +228,12 @@
for qw(get_meta_instance compute_all_applicable_attributes
class_precedence_list get_method_map );
}
+
+{
+ Foo->meta->make_immutable;
+ Bar->meta->make_immutable;
+ Bar->meta->make_mutable;
+
+ isnt( Foo->meta->get_immutable_transformer, Bar->meta->get_immutable_transformer,
+ 'Foo and Bar should have different immutable transformer objects' );
+}
More information about the Moose-commits
mailing list