This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix the error message "Can't call method "DOES" on unblessed
[perl5.git] / universal.c
index adfddb5..182b5c9 100644 (file)
@@ -185,6 +185,7 @@ Perl_sv_does(pTHX_ SV *sv, const char *name)
 {
     const char *classname;
     bool does_it;
+    SV *methodname;
 
     dSP;
     ENTER;
@@ -210,7 +211,12 @@ Perl_sv_does(pTHX_ SV *sv, const char *name)
     XPUSHs(sv_2mortal(newSVpv(name, 0)));
     PUTBACK;
 
-    call_method("isa", G_SCALAR);
+    methodname = sv_2mortal(newSVpv("isa", 0));
+    /* ugly hack: use the SvSCREAM flag so S_method_common
+     * can figure out we're calling DOES() and not isa(),
+     * and report eventual errors correctly. --rgs */
+    SvSCREAM_on(methodname);
+    call_sv(methodname, G_SCALAR | G_METHOD);
     SPAGAIN;
 
     does_it = SvTRUE( TOPs );