[Moose-commits] r7579 - Class-MOP/trunk/lib/Class
autarch at code2.0beta.co.uk
autarch at code2.0beta.co.uk
Sun Feb 8 15:08:27 GMT 2009
Author: autarch
Date: 2009-02-08 07:08:27 -0800 (Sun, 08 Feb 2009)
New Revision: 7579
Modified:
Class-MOP/trunk/lib/Class/MOP.pm
Log:
Improve is_class_loaded checking
Modified: Class-MOP/trunk/lib/Class/MOP.pm
===================================================================
--- Class-MOP/trunk/lib/Class/MOP.pm 2009-02-08 15:07:54 UTC (rev 7578)
+++ Class-MOP/trunk/lib/Class/MOP.pm 2009-02-08 15:08:27 UTC (rev 7579)
@@ -9,7 +9,7 @@
use MRO::Compat;
use Carp 'confess';
-use Scalar::Util 'weaken';
+use Scalar::Util 'weaken', 'reftype';
use Class::MOP::Class;
@@ -186,9 +186,19 @@
$pack = \*{${$$pack}{"${part}::"}};
}
- # check for $VERSION or @ISA
- return 1 if exists ${$$pack}{VERSION}
- && defined *{${$$pack}{VERSION}}{SCALAR};
+ # We used to check in the package stash, but it turns out that
+ # *{${$$package}{VERSION}{SCALAR}} can end up pointing to a
+ # reference to undef. It looks
+
+ my $version = do {
+ no strict 'refs';
+ ${$class . '::VERSION'};
+ };
+
+ return 1 if ! ref $version && defined $version;
+ # Sometimes $VERSION ends up as a reference to undef (weird)
+ return 1 if ref $version && reftype $version eq 'SCALAR' && defined ${$version};
+
return 1 if exists ${$$pack}{ISA}
&& defined *{${$$pack}{ISA}}{ARRAY};
More information about the Moose-commits
mailing list