[Moose-commits] r7291 - in Moose/trunk: . lib lib/Moose/Meta/Method
autarch at code2.0beta.co.uk
autarch at code2.0beta.co.uk
Mon Jan 12 00:52:42 GMT 2009
Author: autarch
Date: 2009-01-11 16:52:42 -0800 (Sun, 11 Jan 2009)
New Revision: 7291
Modified:
Moose/trunk/Changes
Moose/trunk/lib/Moose.pm
Moose/trunk/lib/Moose/Meta/Method/Overriden.pm
Log:
Fix the super recursion bug perigrin found
Modified: Moose/trunk/Changes
===================================================================
--- Moose/trunk/Changes 2009-01-12 00:48:51 UTC (rev 7290)
+++ Moose/trunk/Changes 2009-01-12 00:52:42 UTC (rev 7291)
@@ -1,6 +1,11 @@
Revision history for Perl extension Moose
-Pending
+0.65
+ * Moose and Moose::Meta::Method::Overridden
+ - If an overridden method called super(), and then the
+ superclass's method (not overridden) _also_ called super(),
+ Moose went into an endless recursion loop. Test provided by
+ Chris Prather. (Dave Rolsky)
* Moose::Meta::TypeConstraint
- Add some explanation for a few explanationless methods (gphat)
Modified: Moose/trunk/lib/Moose/Meta/Method/Overriden.pm
===================================================================
--- Moose/trunk/lib/Moose/Meta/Method/Overriden.pm 2009-01-12 00:48:51 UTC (rev 7290)
+++ Moose/trunk/lib/Moose/Meta/Method/Overriden.pm 2009-01-12 00:52:42 UTC (rev 7291)
@@ -16,7 +16,7 @@
# it is really more like body's compilation stash
# this is where we need to override the definition of super() so that the
# body of the code can call the right overridden version
- my $_super_package = $args{package} || $args{class}->name;
+ my $super_package = $args{package} || $args{class}->name;
my $name = $args{name};
@@ -30,13 +30,14 @@
my $method = $args{method};
my $body = sub {
+ local $Moose::SUPER_PACKAGE = $super_package;
local @Moose::SUPER_ARGS = @_;
local $Moose::SUPER_BODY = $super_body;
return $method->(@_);
};
# FIXME do we need this make sure this works for next::method?
- # subname "${_super_package}::${name}", $method;
+ # subname "${super_package}::${name}", $method;
# FIXME store additional attrs
$class->wrap(
Modified: Moose/trunk/lib/Moose.pm
===================================================================
--- Moose/trunk/lib/Moose.pm 2009-01-12 00:48:51 UTC (rev 7290)
+++ Moose/trunk/lib/Moose.pm 2009-01-12 00:52:42 UTC (rev 7291)
@@ -94,8 +94,15 @@
Moose::Util::add_method_modifier($class, 'around', \@_);
}
+our $SUPER_PACKAGE;
+our $SUPER_BODY;
+our @SUPER_ARGS;
+
sub super {
- return unless our $SUPER_BODY; $SUPER_BODY->(our @SUPER_ARGS);
+ # This check avoids a recursion loop - see
+ # t/100_bugs/020_super_recursion.t
+ return if defined $SUPER_PACKAGE && $SUPER_PACKAGE ne caller();
+ return unless $SUPER_BODY; $SUPER_BODY->(@SUPER_ARGS);
}
sub override {
More information about the Moose-commits
mailing list