diff options
author | Father Chrysostomos <sprout@cpan.org> | 2013-12-04 16:00:48 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2013-12-04 21:20:51 -0800 |
commit | 257dc59d7b864a6cf0ccc9179de1f3f0a797f4e0 (patch) | |
tree | 302d3f4351fca49e715746900560052eff9f6d53 /t/op/method.t | |
parent | 522b3c1ed452af6cfa7979f3283556433ebb4a26 (diff) | |
download | perl-257dc59d7b864a6cf0ccc9179de1f3f0a797f4e0.tar.gz |
[perl #120694] Fix ->SUPER::foo and AUTOLOAD
Commit aae438050a20 (5.17.4) broke ->SUPER::foo with AUTOLOAD by look-
ing up AUTOLOAD from the current package, rather than the current
package’s superclass.
Instead of keeping track of whether it was doing a SUPER lookup via a
::SUPER prefix on the package name, that commit changed method lookup
to pass a GV_SUPER flag around (to fix another bug) and to pass the
current stash, rather than __PACKAGE__::SUPER. But it did not update
gv_autoload_pvn to pass that flag through to gv_fetchmeth_pvn when
actually looking up the method.
Diffstat (limited to 't/op/method.t')
-rw-r--r-- | t/op/method.t | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/t/op/method.t b/t/op/method.t index d206fc75fe..059b44f49c 100644 --- a/t/op/method.t +++ b/t/op/method.t @@ -13,7 +13,7 @@ BEGIN { use strict; no warnings 'once'; -plan(tests => 146); +plan(tests => 147); @A::ISA = 'B'; @B::ISA = 'C'; @@ -268,6 +268,27 @@ sub OtherSouper::method { "Isidore Ropen, Draft Manager" } 'SUPER inside moved package respects method changes'; } +package foo120694 { + BEGIN { our @ISA = qw(bar120694) } + + sub AUTOLOAD { + my $self = shift; + local our $recursive = $recursive; + return "recursive" if $recursive++; + return if our $AUTOLOAD eq 'DESTROY'; + $AUTOLOAD = "SUPER:" . substr $AUTOLOAD, rindex($AUTOLOAD, ':'); + return $self->$AUTOLOAD(@_); + } +} +package bar120694 { + sub AUTOLOAD { + return "xyzzy"; + } +} +is bless( [] => "foo120694" )->plugh, 'xyzzy', + '->SUPER::method autoloading uses parent of current pkg'; + + # failed method call or UNIVERSAL::can() should not autovivify packages is( $::{"Foo::"} || "none", "none"); # sanity check 1 is( $::{"Foo::"} || "none", "none"); # sanity check 2 |