*::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
{
MAGIC *mg;
AMT *amtp;
+ CV *ret;
if (!stash)
return Nullcv;
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;
}
@INC = '../lib';
}
-print "1..73\n";
+print "1..74\n";
@A::ISA = 'B';
@B::ISA = 'C';
] || $@, '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";