summaryrefslogtreecommitdiff
path: root/t/mro
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2010-12-02 08:30:51 -0800
committerFather Chrysostomos <sprout@cpan.org>2010-12-02 08:38:57 -0800
commit1726bc11330f7a943b1e12c6dd5fa5454b90abd6 (patch)
treef76fc5c513ac2d60b26d0b8da4005620d00b805f /t/mro
parent1245abf13f772bd2dd1d209bf07773efca954acb (diff)
downloadperl-1726bc11330f7a943b1e12c6dd5fa5454b90abd6.tar.gz
[perl #80098] Bleadperl breaks Attribute::Lexical
If @UNIVERSAL::ISA = "a"; and @a::ISA = "b"; then methods are searched for in these orders: main UNIVERSAL a b UNIVERSAL a b UNIVERSAL a b a b UNIVERSAL a b b UNIVERSAL a b For method lookup, looking at a stash twice causes no problems (except for a SUPER bug I’ve just found--to be dealt with separately). My fix to next::method in a5cd004 which made it do a second pass with UNIVERSAL the way gv_fetchmeth does did not take into account that it might return its caller (sub a::foo { return shift->next::can }), causing an infinite loop. This patch makes it check, on the second pass, whether each stash is the stash at the start of the MRO list and breaks if that is the case, so the MROs are effectively: main UNIVERSAL a b UNIVERSAL a b a b UNIVERSAL b UNIVERSAL a (which is what they are effectively already for method lookup).
Diffstat (limited to 't/mro')
-rw-r--r--t/mro/next_edgecases.t16
1 files changed, 14 insertions, 2 deletions
diff --git a/t/mro/next_edgecases.t b/t/mro/next_edgecases.t
index e77ce7be31..3840a4b882 100644
--- a/t/mro/next_edgecases.t
+++ b/t/mro/next_edgecases.t
@@ -5,7 +5,7 @@ use warnings;
BEGIN { chdir 't'; require q(./test.pl); @INC = qw "../lib lib" }
-plan(tests => 14);
+plan(tests => 17);
{
@@ -94,13 +94,15 @@ plan(tests => 14);
}
-# Test next::method with UNIVERSAL methods
+# Test next::method/can with UNIVERSAL methods
{
package UNIVERSAL;
sub foo { "foo" }
+ sub kan { shift->next::can }
our @ISA = "a";
package a;
sub bar { "bar" }
+ sub baz { shift->next::can }
package M;
sub foo { shift->next::method }
sub bar { shift->next::method }
@@ -108,4 +110,14 @@ plan(tests => 14);
is eval { M->foo }, "foo", 'next::method with implicit UNIVERSAL';
is eval { M->bar }, "bar", 'n::m w/superclass of implicit UNIVERSAL';
+
+ is baz a, undef,
+ 'univ superclasses next::cannot their own methods';
+ is kan UNIVERSAL, undef,
+ 'UNIVERSAL next::cannot its own methods';
+
+ @a::ISA = 'b';
+ sub b::cnadd { shift->next::can }
+ is baz b, \&a::baz,
+ 'univ supersuperclass noxt::can method in its immediate subclasses';
}