actually, only do the weird special casing on broken perl versions 0.10
Jesse Luehrs [Wed, 27 Oct 2010 18:13:40 +0000 (13:13 -0500)]
Changes
lib/Package/Stash.pm

diff --git a/Changes b/Changes
index 91069cc..fb7b9ec 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,6 +1,7 @@
 Revision history for Package-Stash
 
 {{$NEXT}}
+      - only do the weird ISA special-casing on perl versions where it's broken
 
 0.09  2010-10-27
       - clean up the vivication code a lot, make it behave more sanely
index f708bbc..6c361c1 100644 (file)
@@ -6,6 +6,9 @@ use warnings;
 use Carp qw(confess);
 use Scalar::Util qw(reftype);
 use Symbol;
+# before 5.12, assigning to the ISA glob would make it lose its magical ->isa
+# powers
+use constant BROKEN_ISA_ASSIGNMENT => ($] < 5.012);
 
 =head1 SYNOPSIS
 
@@ -233,12 +236,15 @@ sub get_package_symbol {
     if (!exists $namespace->{$name}) {
         if ($opts{vivify}) {
             if ($type eq 'ARRAY') {
-                $self->add_package_symbol(
-                    $variable,
-                    # setting our own arrayref manually loses the magicalness
-                    # or something
-                    $name eq 'ISA' ? () : ([])
-                );
+                if (BROKEN_ISA_ASSIGNMENT) {
+                    $self->add_package_symbol(
+                        $variable,
+                        $name eq 'ISA' ? () : ([])
+                    );
+                }
+                else {
+                    $self->add_package_symbol($variable, []);
+                }
             }
             elsif ($type eq 'HASH') {
                 $self->add_package_symbol($variable, {});