From: Jesse Luehrs Date: Fri, 1 Oct 2010 00:18:58 +0000 (-0500) Subject: make weakening of anon classes explicit X-Git-Tag: 1.10~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3b76e0d5b9d738dc5e076afe26af9c32e4d2419b;p=gitmo%2FClass-MOP.git make weakening of anon classes explicit --- diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index 0c9e9d7..1b09a81 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -109,7 +109,7 @@ sub _construct_class_instance { # NOTE: # we need to weaken any anon classes # so that they can call DESTROY properly - Class::MOP::weaken_metaclass($package_name) if $meta->is_anon_class; + Class::MOP::weaken_metaclass($package_name) if $options->{weaken}; $meta; } @@ -444,6 +444,7 @@ sub _remove_generated_metaobjects { sub create_anon_class { my ($class, %options) = @_; + $options{weaken} = 1 unless exists $options{weaken}; my $package_name = $ANON_CLASS_PREFIX . ++$ANON_CLASS_SERIAL; return $class->create($package_name, %options); } diff --git a/t/048_anon_class_create_init.t b/t/048_anon_class_create_init.t index 6051f15..aa71442 100644 --- a/t/048_anon_class_create_init.t +++ b/t/048_anon_class_create_init.t @@ -96,7 +96,6 @@ my $instance; weaken => 0, )->name; } - local $TODO = "non-weak anon classes not implemented yet"; ok(Class::MOP::class_of($meta_name), "metaclass still exists"); { my $bar_meta;