This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade to Test::Simple 0.80, but keep locally modified More.t
[perl5.git] / lib / NEXT.pm
index 1c6a316..57e2b41 100644 (file)
@@ -1,7 +1,8 @@
 package NEXT;
-$VERSION = '0.60_01';
+$VERSION = '0.60_02';
 use Carp;
 use strict;
+use overload ();
 
 sub NEXT::ELSEWHERE::ancestors
 {
@@ -42,11 +43,13 @@ sub AUTOLOAD
        croak "Can't call $wanted from $caller"
                unless $caller_method eq $wanted_method;
 
-       local ($NEXT::NEXT{$self,$wanted_method}, $NEXT::SEEN) =
-             ($NEXT::NEXT{$self,$wanted_method}, $NEXT::SEEN);
+       my $key = ref $self && overload::Overloaded($self)
+           ? overload::StrVal($self) : $self;
 
+       local ($NEXT::NEXT{$key,$wanted_method}, $NEXT::SEEN) =
+             ($NEXT::NEXT{$key,$wanted_method}, $NEXT::SEEN);
 
-       unless ($NEXT::NEXT{$self,$wanted_method}) {
+       unless ($NEXT::NEXT{$key,$wanted_method}) {
                my @forebears =
                        NEXT::ELSEWHERE::ancestors ref $self || $self,
                                                   $wanted_class;
@@ -54,19 +57,19 @@ sub AUTOLOAD
                        last if shift @forebears eq $caller_class
                }
                no strict 'refs';
-               @{$NEXT::NEXT{$self,$wanted_method}} = 
+               @{$NEXT::NEXT{$key,$wanted_method}} = 
                        map { *{"${_}::$caller_method"}{CODE}||() } @forebears
                                unless $wanted_method eq 'AUTOLOAD';
-               @{$NEXT::NEXT{$self,$wanted_method}} = 
+               @{$NEXT::NEXT{$key,$wanted_method}} = 
                        map { (*{"${_}::AUTOLOAD"}{CODE}) ? "${_}::AUTOLOAD" : ()} @forebears
-                               unless @{$NEXT::NEXT{$self,$wanted_method}||[]};
-               $NEXT::SEEN->{$self,*{$caller}{CODE}}++;
+                               unless @{$NEXT::NEXT{$key,$wanted_method}||[]};
+               $NEXT::SEEN->{$key,*{$caller}{CODE}}++;
        }
-       my $call_method = shift @{$NEXT::NEXT{$self,$wanted_method}};
+       my $call_method = shift @{$NEXT::NEXT{$key,$wanted_method}};
        while ($wanted_class =~ /^NEXT\b.*\b(UNSEEN|DISTINCT)\b/
               && defined $call_method
-              && $NEXT::SEEN->{$self,$call_method}++) {
-               $call_method = shift @{$NEXT::NEXT{$self,$wanted_method}};
+              && $NEXT::SEEN->{$key,$call_method}++) {
+               $call_method = shift @{$NEXT::NEXT{$key,$wanted_method}};
        }
        unless (defined $call_method) {
                return unless $wanted_class =~ /^NEXT:.*:ACTUAL/;
@@ -103,11 +106,14 @@ sub AUTOLOAD
        undef $EVERY::AUTOLOAD;
        my ($wanted_class, $wanted_method) = $wanted =~ m{(.*)::(.*)}g;
 
-       local $NEXT::ALREADY_IN_EVERY{$self,$wanted_method} =
-             $NEXT::ALREADY_IN_EVERY{$self,$wanted_method};
+       my $key = ref($self) && overload::Overloaded($self)
+           ? overload::StrVal($self) : $self;
+
+       local $NEXT::ALREADY_IN_EVERY{$key,$wanted_method} =
+             $NEXT::ALREADY_IN_EVERY{$key,$wanted_method};
+
+       return if $NEXT::ALREADY_IN_EVERY{$key,$wanted_method}++;
 
-       return if $NEXT::ALREADY_IN_EVERY{$self,$wanted_method}++;
-       
        my @forebears = NEXT::ELSEWHERE::ordered_ancestors ref $self || $self,
                                                           $wanted_class;
        @forebears = reverse @forebears if $wanted_class =~ /\bLAST\b/;
@@ -233,7 +239,7 @@ do better.
 
 By default, if a redispatch attempt fails to find another method
 elsewhere in the objects class hierarchy, it quietly gives up and does
-nothing (but see L<"Enforcing redispatch">). This gracious acquiesence
+nothing (but see L<"Enforcing redispatch">). This gracious acquiescence
 is also unlike the (generally annoying) behaviour of C<SUPER>, which
 throws an exception if it cannot redispatch.
 
@@ -420,7 +426,7 @@ order. Instead, they are called "breadth-first-dependency-wise".
 That means that the inheritance tree of the object is traversed breadth-first
 and the resulting order of classes is used as the sequence in which methods
 are called. However, that sequence is modified by imposing a rule that the
-appropritae method of a derived class must be called before the same method of
+appropriate method of a derived class must be called before the same method of
 any ancestral class. That's why, in the above example, C<X::foo> is called
 before C<D::foo>, even though C<D> comes before C<X> in C<@B::ISA>.