This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #47047] Fix erroneous AUTOLOAD warning
authorFather Chrysostomos <sprout@cpan.org>
Mon, 5 Sep 2016 16:31:31 +0000 (09:31 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 5 Sep 2016 16:32:39 +0000 (09:32 -0700)
If there was a stub present in the package into which the invocant had
been blessed, then AUTOLOADing via a *method* call would warn with â€˜Use
of inherited AUTOLOAD for non-method’ even if it is a method.

A recent commit stopped OPf_REF from being set on OP_ENTERSUB, so this
commit uses that flag to indicate a method call, to allow a fast run-
time check to see whether to pass the method flag to gv_autoload.

op.c
pp_hot.c

diff --git a/op.c b/op.c
index 4c9ae50..10a6db1 100644 (file)
--- a/op.c
+++ b/op.c
@@ -11944,6 +11944,7 @@ Perl_ck_subr(pTHX_ OP *o)
        case OP_METHOD_SUPER:
        case OP_METHOD_REDIR:
        case OP_METHOD_REDIR_SUPER:
+           o->op_flags |= OPf_REF;
            if (aop->op_type == OP_CONST) {
                aop->op_private &= ~OPpCONST_STRICT;
                const_class = &cSVOPx(aop)->op_sv;
index a794fd5..9da9ab0 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -3817,7 +3817,10 @@ PP(pp_entersub)
        else {
           try_autoload:
            autogv = gv_autoload_pvn(GvSTASH(gv), GvNAME(gv), GvNAMELEN(gv),
-                                  GvNAMEUTF8(gv) ? SVf_UTF8 : 0);
+                                     (GvNAMEUTF8(gv) ? SVf_UTF8 : 0)
+                                    |(PL_op->op_flags & OPf_REF
+                                       ? GV_AUTOLOAD_ISMETHOD
+                                       : 0));
             cv = autogv ? GvCV(autogv) : NULL;
        }
        if (!cv) {