From: Ilmari Karonen Date: Fri, 5 Apr 2002 01:35:08 +0000 (+0300) Subject: Re: [ID 20020305.025] PACKAGE::SUPER doesn't work anymore X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e189a56d832d31da4b6bb0fcf7dfde76e1fc4b24;p=p5sagit%2Fp5-mst-13.2.git Re: [ID 20020305.025] PACKAGE::SUPER doesn't work anymore Message-ID: p4raw-id: //depot/perl@15737 --- diff --git a/gv.c b/gv.c index 0921095..a89e900 100644 --- a/gv.c +++ b/gv.c @@ -422,9 +422,17 @@ Perl_gv_fetchmethod_autoload(pTHX_ HV *stash, const char *name, I32 autoload) DEBUG_o( Perl_deb(aTHX_ "Treating %s as %s::%s\n", origname, HvNAME(stash), name) ); } - else + else { /* don't autovifify if ->NoSuchStash::method */ stash = gv_stashpvn(origname, nsplit - origname, FALSE); + + /* however, explicit calls to Pkg::SUPER::method may + happen, and may require autovivification to work */ + if (!stash && (nsplit - origname) >= 7 && + strnEQ(nsplit - 7, "::SUPER", 7) && + gv_stashpvn(origname, nsplit - origname - 7, FALSE)) + stash = gv_stashpvn(origname, nsplit - origname, TRUE); + } } gv = gv_fetchmeth(stash, name, nend - name, 0); diff --git a/t/op/method.t b/t/op/method.t index 16a927a..46c1119 100755 --- a/t/op/method.t +++ b/t/op/method.t @@ -10,7 +10,7 @@ BEGIN { require "test.pl"; } -print "1..74\n"; +print "1..75\n"; @A::ISA = 'B'; @B::ISA = 'C'; @@ -259,3 +259,21 @@ is( is($w, ''); } +# [ID 20020305.025] PACKAGE::SUPER doesn't work anymore + +package main; +our @X; +package Amajor; +sub test { + push @main::X, 'Amajor', @_; +} +package Bminor; +use base qw(Amajor); +package main; +sub Bminor::test { + $_[0]->Bminor::SUPER::test('x', 'y'); + push @main::X, 'Bminor', @_; +} +Bminor->test('y', 'z'); +is("@X", "Amajor Bminor x y Bminor Bminor y z"); +