summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-10-17 16:24:58 -0400
committerJesse Luehrs <doy@tozt.net>2013-10-17 16:58:34 -0400
commitd70bfb04654edb2c690488bcaace7a1c7090004d (patch)
treee9af4f5886e7a1ef94e2290866f1e4e41aaf72a5
parent80931db166568dce568bdcb2dea79a1dfebf1c15 (diff)
downloadperl-d70bfb04654edb2c690488bcaace7a1c7090004d.tar.gz
isa should fall back to checking @UNIVERSAL::ISA in all cases
-rw-r--r--t/op/universal.t9
-rw-r--r--universal.c12
2 files changed, 16 insertions, 5 deletions
diff --git a/t/op/universal.t b/t/op/universal.t
index 7b5cdb06de..50d1782384 100644
--- a/t/op/universal.t
+++ b/t/op/universal.t
@@ -10,7 +10,7 @@ BEGIN {
require "./test.pl";
}
-plan tests => 142;
+plan tests => 144;
$a = {};
bless $a, "Bob";
@@ -343,3 +343,10 @@ ok(Undeclared->can("foo"));
ok(!Undeclared->can("something_else"));
ok(Undeclared->isa("UNIVERSAL"));
+
+# keep this at the end to avoid messing up earlier tests, since it modifies
+# @UNIVERSAL::ISA
+@UNIVERSAL::ISA = ('UniversalParent');
+{ package UniversalIsaTest1; }
+ok(UniversalIsaTest1->isa('UniversalParent'));
+ok(UniversalIsaTest2->isa('UniversalParent'));
diff --git a/universal.c b/universal.c
index 8337e2b4e0..305713fcba 100644
--- a/universal.c
+++ b/universal.c
@@ -160,15 +160,19 @@ Perl_sv_derived_from_pvn(pTHX_ SV *sv, const char *const name, const STRLEN len,
type = sv_reftype(sv,0);
if (type && strEQ(type,name))
return TRUE;
- stash = SvOBJECT(sv) ? SvSTASH(sv) : NULL;
+ if (!SvOBJECT(sv))
+ return FALSE;
+ stash = SvSTASH(sv);
}
else {
stash = gv_stashsv(sv, 0);
- if (!stash)
- stash = gv_stashpvs("UNIVERSAL", 0);
}
- return stash ? isa_lookup(stash, name, len, flags) : FALSE;
+ if (stash && isa_lookup(stash, name, len, flags))
+ return TRUE;
+
+ stash = gv_stashpvs("UNIVERSAL", 0);
+ return stash && isa_lookup(stash, name, len, flags);
}
/*