bump version to 0.90
[gitmo/Moose.git] / lib / Moose / Object.pm
index fefdfe3..12ea2f0 100644 (file)
@@ -7,21 +7,23 @@ use warnings;
 use Devel::GlobalDestruction qw(in_global_destruction);
 use MRO::Compat;
 use Scalar::Util;
+use Try::Tiny;
 
 use if ( not our $__mx_is_compiled ), 'Moose::Meta::Class';
 use if ( not our $__mx_is_compiled ), metaclass => 'Moose::Meta::Class';
 
-our $VERSION   = '0.89_02';
+our $VERSION   = '0.90';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
 sub new {
     my $class = shift;
 
+    Carp::cluck 'Calling new() on an instance is deprecated,'
+      . ' please use (blessed $obj)->new' if blessed $class;
+
     my $params = $class->BUILDARGS(@_);
 
-    # We want to support passing $self->new, but initialize
-    # takes only an unblessed class name
     my $real_class = Scalar::Util::blessed($class) || $class;
     my $self = Class::MOP::Class->initialize($real_class)->new_object($params);
 
@@ -86,8 +88,20 @@ sub DEMOLISHALL {
 }
 
 sub DESTROY {
-    local ( $., $@, $!, $^E, $? );
-    $_[0]->DEMOLISHALL(in_global_destruction);
+    my $self = shift;
+
+    local $?;
+
+    try {
+        $self->DEMOLISHALL(in_global_destruction);
+    }
+    catch {
+        # Without this, Perl will warn "\t(in cleanup)$@" because of some
+        # bizarre fucked-up logic deep in the internals.
+        no warnings 'misc';
+        die $_;
+    };
+
     return;
 }