Skip to content

Commit

Permalink
Make the default type constraint Any instead of Defined.
Browse files Browse the repository at this point in the history
  • Loading branch information
rafl committed Feb 3, 2010
1 parent 5d956eb commit 8102fc7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile.PL
Expand Up @@ -16,7 +16,7 @@ requires 'MooseX::LazyRequire' => '0.04';
requires 'MooseX::Meta::TypeConstraint::ForceCoercion';
requires 'MooseX::Types' => '0.19';
requires 'MooseX::Types::Moose';
requires 'MooseX::Types::Structured' => '0.12';
requires 'MooseX::Types::Structured' => '0.20';
requires 'namespace::autoclean';
requires 'Sub::Name';
requires 'Task::Weaken';
Expand Down
8 changes: 3 additions & 5 deletions lib/MooseX/Method/Signatures/Meta/Method.pm
Expand Up @@ -11,7 +11,7 @@ use Moose::Util::TypeConstraints;
use MooseX::Meta::TypeConstraint::ForceCoercion;
use MooseX::Types::Util qw/has_available_type_export/;
use MooseX::Types::Structured qw/Tuple Dict Optional slurpy/;
use MooseX::Types::Moose qw/ArrayRef Str Maybe Object Defined CodeRef Bool/;
use MooseX::Types::Moose qw/ArrayRef Str Maybe Object Any CodeRef Bool/;
use MooseX::Method::Signatures::Types qw/Injections Params/;
use aliased 'Parse::Method::Signatures::Param::Named';
use aliased 'Parse::Method::Signatures::Param::Placeholder';
Expand Down Expand Up @@ -232,7 +232,7 @@ sub _build__return_type_constraint {
sub _param_to_spec {
my ($self, $param) = @_;

my $tc = Defined;
my $tc = Any;
{
# Ensure errors get reported from the right place
local $Carp::Internal{'MooseX::Method::Signatures::Meta::Method'} = 1;
Expand All @@ -258,9 +258,7 @@ sub _param_to_spec {

$spec{tc} = $param->required
? $tc
: does_role($param, Named)
? Optional[$tc]
: Maybe[$tc];
: Optional[$tc];

$spec{default} = $param->default_value
if $param->has_default_value;
Expand Down
8 changes: 4 additions & 4 deletions t/structured.t
Expand Up @@ -2,7 +2,7 @@ use strict;
use warnings;
use Test::More tests => 18;
use Moose::Util::TypeConstraints;
use MooseX::Types::Moose qw/Defined Object Maybe Str Int/;
use MooseX::Types::Moose qw/Any Object Maybe Str Int/;
use MooseX::Types::Structured qw/Dict Tuple Optional/;
use MooseX::Method::Signatures;

Expand All @@ -14,7 +14,7 @@ my $o = bless {}, 'Class';
return "${\ref $self} ${foo} ${bar}";
};

my $expected = Tuple[Tuple[Object,Defined,Maybe[Defined]], Dict[]];
my $expected = Tuple[Tuple[Object,Any,Optional[Any]], Dict[]];
is($meth->type_constraint->name, $expected->name);

eval {
Expand All @@ -39,7 +39,7 @@ my $o = bless {}, 'Class';
return "${\ref $self} ${foo} ${bar}";
};

my $expected = Tuple[Tuple[Object], Dict[foo => Defined, bar => Optional[Defined]]];
my $expected = Tuple[Tuple[Object], Dict[foo => Any, bar => Optional[Any]]];
is($meth->type_constraint->name, $expected->name);

eval {
Expand Down Expand Up @@ -73,7 +73,7 @@ my $o = bless {}, 'Class';
return "${class} ${foo} ${bar}";
};

my $expected = Tuple[Tuple[Defined, Str, subtype(Int, where { $_ % 2 == 0 })], Dict[]];
my $expected = Tuple[Tuple[Any, Str, subtype(Int, where { $_ % 2 == 0 })], Dict[]];
is($meth->type_constraint->name, $expected->name);

eval {
Expand Down

0 comments on commit 8102fc7

Please sign in to comment.