From: Dave Rolsky Date: Sat, 14 Mar 2009 18:12:38 +0000 (-0500) Subject: Revert "make re-applying a role to an object instance a no-op." X-Git-Tag: 0.72_01~69 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b02f817d7475f4c503fa90d6f7f79a541c6464c9;p=gitmo%2FMoose.git Revert "make re-applying a role to an object instance a no-op." The fix is to just check for this oneself: Role->meta->apply($obj) unless $obj->meta->does_role('Role'); This reverts commit bfe4136962533b04367ff4f5f3c483536c31231d. --- diff --git a/Changes b/Changes index dd15858..2493181 100644 --- a/Changes +++ b/Changes @@ -26,12 +26,6 @@ Revision history for Perl extension Moose - Allow a subclass to set lazy_build for an inherited attribute. (Dieter Pearcey). - * Moose::Meta::Role::Application::ToInstance - - Attempting to apply the same role to an object repeatedly is - now a no-op after the first application. Previously, doing - this to an object instance eventually caused recursion - warnings from Perl. Reported by Curtis Poe. RT #43904. - 0.72 Mon, February 23, 2009 * Moose::Object * Moose::Meta::Method::Constructor diff --git a/lib/Moose/Meta/Role/Application/ToInstance.pm b/lib/Moose/Meta/Role/Application/ToInstance.pm index 7e5b4d6..411708d 100644 --- a/lib/Moose/Meta/Role/Application/ToInstance.pm +++ b/lib/Moose/Meta/Role/Application/ToInstance.pm @@ -22,11 +22,6 @@ my %ANON_CLASSES; sub apply { my ($self, $role, $object) = @_; - return - if $object->can('meta') - && $object->meta->can('does_role') - && $object->meta->does_role( $role->name ); - my $anon_role_key = (blessed($object) . $role->name); my $class; diff --git a/t/030_roles/010_run_time_role_composition.t b/t/030_roles/010_run_time_role_composition.t index 5005dcd..1a86a18 100644 --- a/t/030_roles/010_run_time_role_composition.t +++ b/t/030_roles/010_run_time_role_composition.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 28; +use Test::More tests => 27; use Scalar::Util qw(blessed); @@ -101,21 +101,6 @@ isa_ok($obj2, 'My::Class'); is(blessed($obj), blessed($obj2), '... they share the same anon-class/role thing again'); } -SKIP: -{ - eval 'use Test::Output;'; - skip 'This test requires Test::Output', 1 - if $@; - - my $obj = My::Class->new; - - stderr_is( - sub { - for ( 1 .. 200 ) { - Sleeper->meta->apply($obj); - } - }, - q{}, - 'No warnings when re-applying a role to an object 200 times' - ); -} + + +