From: Dave Rolsky Date: Mon, 14 Sep 2009 15:34:11 +0000 (-0500) Subject: Revert "add a warning for immutablizing a class with mutable ancestors" X-Git-Tag: 0.90~16 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8756d34f1bbba488d12edb61b89095f5006c601c;p=gitmo%2FMoose.git Revert "add a warning for immutablizing a class with mutable ancestors" This reverts commit 21f1fbdc72bf569ef63bd551217635baa27da689. Conflicts: lib/Moose/Manual/Delta.pod lib/Moose/Meta/Class.pm t/300_immutable/016_immutable_with_mutable_ancestors.t --- diff --git a/Changes b/Changes index fb1a23e..d93c0c5 100644 --- a/Changes +++ b/Changes @@ -55,9 +55,6 @@ Next - If you try to wrap/export a subroutine which doesn't actually exist, Moose::Exporter will warn you about this. (doy) - * Moose::Meta::Class - - Warn when calling make_immutable on a class with mutable ancestors. - (doy) * Moose::Meta::Role::Application::ToRole - When a role aliased a method from another role, it was only getting diff --git a/lib/Moose/Meta/Class.pm b/lib/Moose/Meta/Class.pm index f74b483..a97f0a5 100644 --- a/lib/Moose/Meta/Class.pm +++ b/lib/Moose/Meta/Class.pm @@ -140,34 +140,6 @@ sub add_role { push @{$self->roles} => $role; } -sub make_immutable { - my $self = shift; - - # we do this for metaclasses way too often to do this check for them - if ( !$self->name->isa('Class::MOP::Object') ) { - my @superclasses = grep { $_ ne 'Moose::Object' && $_ ne $self->name } - $self->linearized_isa; - - for my $superclass (@superclasses) { - my $meta = Class::MOP::class_of($superclass); - - next unless $meta && $meta->isa('Moose::Meta::Class'); - next unless $meta->is_mutable; - # This can happen when a base class role is applied via - # Moose::Util::MetaRole::apply_base_class_roles. The parent is an - # anon class and is still mutable, but that's okay. - next if $meta->is_anon_class; - - Carp::cluck( "Calling make_immutable on " - . $self->name - . ", which has a mutable ancestor ($superclass)" ); - last; - } - } - - $self->SUPER::make_immutable(@_); -} - sub role_applications { my ($self) = @_; diff --git a/t/060_compat/003_foreign_inheritence.t b/t/060_compat/003_foreign_inheritence.t index 14649c8..f99cac9 100644 --- a/t/060_compat/003_foreign_inheritence.t +++ b/t/060_compat/003_foreign_inheritence.t @@ -42,8 +42,6 @@ use Test::Exception; __PACKAGE__->meta->add_attribute( 'squeegee' => ( accessor => 'squeegee' ) ); - __PACKAGE__->meta->make_immutable(inline_constructor => 0); - package Old::Bucket::Nose; # see http://www.moosefoundation.org/moose_facts.htm diff --git a/t/300_immutable/005_multiple_demolish_inline.t b/t/300_immutable/005_multiple_demolish_inline.t index 24b110a..c1e509a 100644 --- a/t/300_immutable/005_multiple_demolish_inline.t +++ b/t/300_immutable/005_multiple_demolish_inline.t @@ -28,13 +28,6 @@ use Test::Exception; } lives_ok { - Foo->meta->make_immutable; -} 'Foo->meta->make_immutable'; - -is( Foo->meta->get_method('DESTROY')->package_name, 'Foo', - 'Foo has a DESTROY method in the Foo class (not inherited)' ); - -lives_ok { Bar->new(); } 'Bar->new()'; @@ -44,3 +37,10 @@ lives_ok { is( Bar->meta->get_method('DESTROY')->package_name, 'Bar', 'Bar has a DESTROY method in the Bar class (not inherited)' ); + +lives_ok { + Foo->meta->make_immutable; +} 'Foo->meta->make_immutable'; + +is( Foo->meta->get_method('DESTROY')->package_name, 'Foo', + 'Foo has a DESTROY method in the Bar class (not inherited)' ); diff --git a/t/300_immutable/016_immutable_with_mutable_ancestors.t b/t/300_immutable/016_immutable_with_mutable_ancestors.t deleted file mode 100644 index a36a7e9..0000000 --- a/t/300_immutable/016_immutable_with_mutable_ancestors.t +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -use Test::More; -use Test::Exception; -use lib 't/lib'; - -BEGIN { - eval "use Test::Output;"; - plan skip_all => "Test::Output is required for this test" if $@; - plan tests => 5; -} - -{ - package Foo; - use Moose; -} - -{ - package Foo::Sub; - use Moose; - extends 'Foo'; - - ::stderr_like { - __PACKAGE__->meta->make_immutable - } qr/^Calling make_immutable on Foo::Sub, which has a mutable ancestor \(Foo\)/, - "warning when making a class with mutable ancestors immutable"; -} - -Foo->meta->make_immutable; - -{ - package Foo::Sub2; - use Moose; - extends 'Foo'; - - ::stderr_is { - __PACKAGE__->meta->make_immutable - } '', "no warning when all ancestors are immutable"; -} - -{ - package Foo::Sub3; - use Moose; - extends 'Foo'; -} - -{ - package Foo::Sub3::Sub; - use Moose; - extends 'Foo::Sub3'; -} - -{ - package Foo::Sub3::Sub::Sub; - use Moose; - extends 'Foo::Sub3::Sub'; - - ::stderr_like { - __PACKAGE__->meta->make_immutable - } qr/^Calling make_immutable on Foo::Sub3::Sub::Sub, which has a mutable ancestor \(Foo::Sub3::Sub\)/, - "warning when making a class with mutable ancestors immutable"; -} - -stderr_like { - require Recursive::Parent -} qr/^Calling make_immutable on Recursive::Child, which has a mutable ancestor \(Recursive::Parent\)/, - "circular dependencies via use are caught properly"; - -{ - package Base::Role; - use Moose::Role; - - sub foo { 42 } - - package Bar; - use Moose; - use Moose::Util::MetaRole; - - Moose::Util::MetaRole::apply_base_class_roles( - for_class => __PACKAGE__, - roles => ['Base::Role'], - ); - - ::stderr_is { - __PACKAGE__->meta->make_immutable - } '', "no warning when ancestor is a base-class role subclass of Moose::Object"; -} diff --git a/t/lib/Recursive/Child.pm b/t/lib/Recursive/Child.pm deleted file mode 100644 index 655dc69..0000000 --- a/t/lib/Recursive/Child.pm +++ /dev/null @@ -1,12 +0,0 @@ -package Recursive::Child; -use Moose; -extends 'Recursive::Parent'; - -has parent => ( - is => 'ro', - isa => 'Recursive::Parent', -); - -__PACKAGE__->meta->make_immutable; - -1; diff --git a/t/lib/Recursive/Parent.pm b/t/lib/Recursive/Parent.pm deleted file mode 100644 index 2ffe6f7..0000000 --- a/t/lib/Recursive/Parent.pm +++ /dev/null @@ -1,13 +0,0 @@ -package Recursive::Parent; -use Moose; - -use Recursive::Child; - -has child => ( - is => 'ro', - isa => 'Maybe[Recursive::Child]', -); - -__PACKAGE__->meta->make_immutable; - -1;