summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbhijit Menon-Sen <ams@wiw.org>2002-03-16 02:38:08 +0000
committerAbhijit Menon-Sen <ams@wiw.org>2002-03-16 02:38:08 +0000
commit3ad83ce7d21aa3aa1ac69bde413ed71b6ce30329 (patch)
tree3dbac8a96fbc1b5225f84d2a9d7e4f0984ff860b
parent6e6372ba61ad0832b23176adf895ff047ad66cc7 (diff)
downloadperl-3ad83ce7d21aa3aa1ac69bde413ed71b6ce30329.tar.gz
Subject: [PATCH @15047] Use of inherited AUTOLOAD for non-method
*::DESTROY() is deprecated From: Ilya Zakharevich <ilya@math.ohio-state.edu> Date: Thu, 14 Mar 2002 18:39:22 -0500 Message-Id: <20020314183922.A8448@math.ohio-state.edu> Subject: Re: [PATCH @15047] Use of inherited AUTOLOAD for non-method *::DESTROY() is deprecated From: Dave Mitchell <davem@fdgroup.com> Date: Fri, 15 Mar 2002 19:22:49 +0000 Message-Id: <20020315192249.A22389@fdgroup.com> p4raw-link: @15047 on //depot/perl: 0cce8c827906d6294f47c30840f886b52d8345f8 p4raw-id: //depot/perl@15251
-rw-r--r--gv.c18
-rwxr-xr-xt/op/method.t18
2 files changed, 33 insertions, 3 deletions
diff --git a/gv.c b/gv.c
index 3785a2b465..6fd5ff75df 100644
--- a/gv.c
+++ b/gv.c
@@ -1412,6 +1412,7 @@ Perl_gv_handler(pTHX_ HV *stash, I32 id)
{
MAGIC *mg;
AMT *amtp;
+ CV *ret;
if (!stash)
return Nullcv;
@@ -1425,8 +1426,21 @@ Perl_gv_handler(pTHX_ HV *stash, I32 id)
if ( amtp->was_ok_am != PL_amagic_generation
|| amtp->was_ok_sub != PL_sub_generation )
goto do_update;
- if (AMT_AMAGIC(amtp))
- return amtp->table[id];
+ if (AMT_AMAGIC(amtp)) {
+ ret = amtp->table[id];
+ if (ret && isGV(ret)) { /* Autoloading stab */
+ /* Passing it through may have resulted in a warning
+ "Inherited AUTOLOAD for a non-method deprecated", since
+ our caller is going through a function call, not a method call.
+ So return the CV for AUTOLOAD, setting $AUTOLOAD. */
+ GV *gv = gv_fetchmethod(stash, (char*)PL_AMG_names[id]);
+
+ if (gv && GvCV(gv))
+ return GvCV(gv);
+ }
+ return ret;
+ }
+
return Nullcv;
}
diff --git a/t/op/method.t b/t/op/method.t
index 0d4e09b10a..0ce8ce8dfb 100755
--- a/t/op/method.t
+++ b/t/op/method.t
@@ -9,7 +9,7 @@ BEGIN {
@INC = '../lib';
}
-print "1..73\n";
+print "1..74\n";
@A::ISA = 'B';
@B::ISA = 'C';
@@ -249,4 +249,20 @@ test (
] || $@, 'ok'
);
+# An autoloaded, inherited DESTROY may be invoked differently than normal
+# methods, and has been known to give rise to spurious warnings
+# eg <200203121600.QAA11064@gizmo.fdgroup.co.uk>
+
+{
+ use warnings;
+ my $w = '';
+ local $SIG{__WARN__} = sub { $w = $_[0] };
+
+ sub AutoDest::Base::AUTOLOAD {}
+ @AutoDest::ISA = qw(AutoDest::Base);
+ { my $x = bless {}, 'AutoDest'; }
+ $w =~ s/\n//g;
+ test($w, '');
+}
+
print "# $cnt tests completed\n";