From: gfx Date: Mon, 12 Oct 2009 07:47:11 +0000 (+0900) Subject: Revert "Skip class_type etc stack frames when checking the package that defines a... X-Git-Tag: 0.38~14 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=242604b64bc67c2cb2f66a8016444874b2408e58;p=gitmo%2FMouse.git Revert "Skip class_type etc stack frames when checking the package that defines a subtype" This reverts commit 0608c8c81819673540f51f8ab44b6f3364cae53f. --- diff --git a/lib/Mouse/Util/TypeConstraints.pm b/lib/Mouse/Util/TypeConstraints.pm index 0edd9b6..54246b8 100644 --- a/lib/Mouse/Util/TypeConstraints.pm +++ b/lib/Mouse/Util/TypeConstraints.pm @@ -151,7 +151,7 @@ sub subtype { $name = '__ANON__' if !defined $name; - my $pkg = caller($conf{_caller_level} || 1); + my $pkg = caller; if ($TYPE{$name} && $TYPE_SOURCE{$name} ne $pkg) { Carp::croak "The type constraint '$name' has already been created in $TYPE_SOURCE{$name} and cannot be created again in $pkg"; @@ -218,15 +218,11 @@ sub class_type { if ($conf && $conf->{class}) { # No, you're using this wrong warn "class_type() should be class_type(ClassName). Perhaps you're looking for subtype $name => as '$conf->{class}'?"; - subtype $name => ( - as => $conf->{class}, - caller_level => (($conf->{_caller_level}||0) + 1), - ); + subtype $name => (as => $conf->{class}); } else { subtype $name => ( where => sub { blessed($_) && $_->isa($name) }, - caller_level => (($conf->{_caller_level}||0) + 1), ); } } @@ -236,7 +232,6 @@ sub role_type { my $role = $conf->{role}; subtype $name => ( where => sub { does_role($_, $role) }, - caller_level => (($conf->{_caller_level}||0) + 1), ); } @@ -275,9 +270,8 @@ sub enum { my $name = shift; my %is_valid = map { $_ => 1 } @_; - subtype $name => ( - where => sub { $is_valid{$_} }, - _caller_level => 1, + subtype( + $name => where => sub { $is_valid{$_} } ); }