From: Shawn M Moore Date: Sat, 25 Apr 2009 00:15:44 +0000 (-0400) Subject: Revert "Moose now warns about class implicitly overriding methods from local" X-Git-Tag: 0.76~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f6bee6fe1d579dc3d2ed2952cce9a1556040c8e5;p=gitmo%2FMoose.git Revert "Moose now warns about class implicitly overriding methods from local" This reverts commit d443cad0cbcc03efe89556a96ff231822b59125d. Conflicts: t/030_roles/019_build.t --- diff --git a/lib/Moose/Meta/Role/Application/ToClass.pm b/lib/Moose/Meta/Role/Application/ToClass.pm index b1093b7..624b2d1 100644 --- a/lib/Moose/Meta/Role/Application/ToClass.pm +++ b/lib/Moose/Meta/Role/Application/ToClass.pm @@ -98,15 +98,13 @@ sub apply_attributes { sub apply_methods { my ($self, $role, $class) = @_; - my @implicitly_overridden; - foreach my $method_name ($role->get_method_list) { + unless ($self->is_method_excluded($method_name)) { # it if it has one already if ($class->has_method($method_name) && # and if they are not the same thing ... $class->get_method($method_name)->body != $role->get_method($method_name)->body) { - push @implicitly_overridden, $method_name; next; } else { @@ -132,14 +130,6 @@ sub apply_methods { ); } } - - if (@implicitly_overridden) { - my $plural = @implicitly_overridden > 1 ? "s" : ""; - # we use \n because we have no hope of guessing the right stack frame, - # it's almost certainly never going to be the one above us - warn "The " . $class->name . " class has implicitly overridden the method$plural (" . join(', ', @implicitly_overridden) . ") from role " . $role->name . ". If this is intentional, please exclude the method$plural from composition to silence this warning (see Moose::Cookbook::Roles::Recipe2)\n"; - } - # we must reset the cache here since # we are just aliasing methods, otherwise # the modifiers go wonky. diff --git a/t/030_roles/003_apply_role.t b/t/030_roles/003_apply_role.t index fded07f..1ccff67 100644 --- a/t/030_roles/003_apply_role.t +++ b/t/030_roles/003_apply_role.t @@ -3,9 +3,8 @@ use strict; use warnings; -use Test::More tests => 87; +use Test::More tests => 86; use Test::Exception; -use Test::Output; { package FooRole; @@ -44,10 +43,7 @@ use Test::Output; use Moose; extends 'BarClass'; - - ::stderr_like { - with 'FooRole'; - } qr/The FooClass class has implicitly overridden the method \(goo\) from role FooRole\. If this is intentional, please exclude the method from composition to silence this warning \(see Moose::Cookbook::Roles::Recipe2\)/; + with 'FooRole'; sub blau {'FooClass::blau'} # << the role wraps this ... diff --git a/t/030_roles/005_role_conflict_detection.t b/t/030_roles/005_role_conflict_detection.t index a9e4f87..b99b90f 100644 --- a/t/030_roles/005_role_conflict_detection.t +++ b/t/030_roles/005_role_conflict_detection.t @@ -3,9 +3,8 @@ use strict; use warnings; -use Test::More tests => 89; +use Test::More tests => 87; # it's really 124 with kolibrie's tests; use Test::Exception; -use Test::Output; =pod @@ -108,11 +107,7 @@ Role method conflicts ::lives_ok { with 'Role::Bling'; - - ::stderr_like { - with 'Role::Bling::Bling'; - } qr/The My::Test4 class has implicitly overridden the method \(bling\) from role Role::Bling::Bling\./; - + with 'Role::Bling::Bling'; } '... role methods didnt conflict when manually combined'; package My::Test5; @@ -120,10 +115,7 @@ Role method conflicts ::lives_ok { with 'Role::Bling::Bling'; - - ::stderr_like { - with 'Role::Bling'; - } qr/The My::Test5 class has implicitly overridden the method \(bling\) from role Role::Bling\./; + with 'Role::Bling'; } '... role methods didnt conflict when manually combined (in opposite order)'; package My::Test6; diff --git a/t/030_roles/011_overriding.t b/t/030_roles/011_overriding.t index d4c24eb..75afe7a 100644 --- a/t/030_roles/011_overriding.t +++ b/t/030_roles/011_overriding.t @@ -3,9 +3,8 @@ use strict; use warnings; -use Test::More tests => 44; +use Test::More tests => 39; use Test::Exception; -use Test::Output; @@ -35,9 +34,7 @@ use Test::Output; use Moose; ::lives_ok { - ::stderr_like { - with qw(Role::C); - } qr/The Class::A class has implicitly overridden the method \(zot\) from role Role::C\./; + with qw(Role::C); } "define class A"; sub zot { 'Class::A::zot' } @@ -73,9 +70,7 @@ is( Class::A->new->xxy, "Role::B::xxy", "... got the right xxy method" ); use Moose; ::lives_ok { - ::stderr_like { - with 'Role::A::Conflict'; - } qr/The Class::A::Resolved class has implicitly overridden the method \(bar\) from role Role::A::Conflict\./; + with 'Role::A::Conflict'; } '... did fufill the requirement of &bar method'; sub bar { 'Class::A::Resolved::bar' } @@ -117,9 +112,7 @@ is( Class::A::Resolved->new->bar, 'Class::A::Resolved::bar', "... got the right use Moose; ::lives_ok { - ::stderr_like { - with qw(Role::F); - } qr/The Class::B class has implicitly overridden the method \(zot\) from role Role::F\./; + with qw(Role::F); } "define class Class::B"; sub zot { 'Class::B::zot' } @@ -196,9 +189,7 @@ ok(Role::D::And::E::Conflict->meta->requires_method('bar'), '... Role::D::And::E use Moose; ::lives_ok { - ::stderr_like { - with qw(Role::I); - } qr/The Class::E class has implicitly overridden the method \(zot\) from role Role::I\./; + with qw(Role::I); } "resolved with method"; sub foo { 'Class::E::foo' } @@ -223,9 +214,7 @@ ok(Role::I->meta->requires_method('foo'), '... Role::I still have the &foo requi sub zot { 'Class::D::zot' } - ::stderr_like { - with qw(Role::I); - } qr/The Class::D class has implicitly overridden the method \(zot\) from role Role::I\./; + with qw(Role::I); } "resolved with attr"; diff --git a/t/030_roles/019_build.t b/t/030_roles/019_build.t index 3e65149..52207d5 100644 --- a/t/030_roles/019_build.t +++ b/t/030_roles/019_build.t @@ -1,7 +1,7 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 10; +use Test::More tests => 8; use Test::Output; # this test script ensures that my idiom of: @@ -24,9 +24,9 @@ do { package ClassWithBUILD; use Moose; - ::stderr_like { + ::stderr_is { with 'TestRole'; - } qr/The ClassWithBUILD class has implicitly overridden the method \(BUILD\) from role TestRole\./; + } ''; sub BUILD { push @CALLS, 'ClassWithBUILD::BUILD' } }; @@ -59,14 +59,6 @@ do { 'TestRole::BUILD:after', ]); - ExplicitClassWithBUILD->new; - - is_deeply([splice @CALLS], [ - 'TestRole::BUILD:before', - 'ExplicitClassWithBUILD::BUILD', - 'TestRole::BUILD:after', - ]); - ClassWithoutBUILD->new; is_deeply([splice @CALLS], [ @@ -77,7 +69,6 @@ do { if (ClassWithBUILD->meta->is_mutable) { ClassWithBUILD->meta->make_immutable; - ExplicitClassWithBUILD->meta->make_immutable; ClassWithoutBUILD->meta->make_immutable; redo; } diff --git a/t/200_examples/001_example.t b/t/200_examples/001_example.t index 3488cf0..473da12 100644 --- a/t/200_examples/001_example.t +++ b/t/200_examples/001_example.t @@ -3,9 +3,8 @@ use strict; use warnings; -use Test::More tests => 22; +use Test::More tests => 20; use Test::Exception; -use Test::Output; @@ -53,9 +52,7 @@ use Test::Output; package Constraint::AtLeast; use Moose; - ::stderr_is { - with 'Constraint' => { excludes => 'error_message' }; - } ""; + with 'Constraint'; sub validate { my ($self, $field) = @_; @@ -67,9 +64,7 @@ use Test::Output; package Constraint::NoMoreThan; use Moose; - ::stderr_is { - with 'Constraint' => { excludes => 'error_message' }; - } ''; + with 'Constraint'; sub validate { my ($self, $field) = @_; diff --git a/t/600_todo_tests/002_various_role_shit.t b/t/600_todo_tests/002_various_role_shit.t index 96719ab..7a44274 100644 --- a/t/600_todo_tests/002_various_role_shit.t +++ b/t/600_todo_tests/002_various_role_shit.t @@ -3,9 +3,8 @@ use strict; use warnings; -use Test::More tests => 40; +use Test::More tests => 39; use Test::Exception; -use Test::Output; sub req_or_has ($$) { my ( $role, $method ) = @_; @@ -100,9 +99,7 @@ sub req_or_has ($$) { package Foo; use Moose; - ::stderr_like { - with qw(Bar); - } qr/The Foo class has implicitly overridden the method \(xxy\) from role Bar\./; + with qw(Bar); has oink => ( is => "rw", @@ -138,7 +135,6 @@ sub req_or_has ($$) { { local our $TODO = "attrs and methods from a role should clash"; - local $SIG{__WARN__} = sub { 'Ignore!' }; ::dies_ok { with qw(Tree Dog) } } }