@@ -12,7 +12,6 @@ use MooseX::Types::Util qw( filter_tags );
1212use MooseX::Types::UndefinedType;
1313use MooseX::Types::CheckedUtilExports ();
1414use Carp::Clan qw( ^MooseX::Types ) ;
15- use Sub::Defer qw( defer_sub ) ;
1615use Sub::Name;
1716use Scalar::Util qw( reftype ) ;
1817use Sub::Exporter::ForMethods 0.100052 ' method_installer' ; # for 'rebless'
@@ -487,20 +486,17 @@ This generates a coercion handler function, e.g. C<to_Int($value)>.
487486
488487sub coercion_export_generator {
489488 my ($class , $type , $full , $undef_msg ) = @_ ;
490- return defer_sub undef , sub {
489+ return sub {
491490 my ($value ) = @_ ;
492491
493492 # we need a type object
494493 my $tobj = find_type_constraint($full ) or croak $undef_msg ;
494+ my $return = $tobj -> coerce($value );
495495
496- return sub {
497- my $ return = $tobj -> coerce( $_ [0] );
496+ # non-successful coercion returns false
497+ return unless $tobj -> check( $return );
498498
499- # non-successful coercion returns false
500- return unless $tobj -> check($return );
501-
502- return $return ;
503- };
499+ return $return ;
504500 }
505501}
506502
@@ -512,16 +508,13 @@ Generates a constraint check closure, e.g. C<is_Int($value)>.
512508
513509sub check_export_generator {
514510 my ($class , $type , $full , $undef_msg ) = @_ ;
515-
516- return defer_sub undef , sub {
511+ return sub {
517512 my ($value ) = @_ ;
518513
519514 # we need a type object
520515 my $tobj = find_type_constraint($full ) or croak $undef_msg ;
521516
522- # This method will actually compile an inlined sub if possible. If
523- # not, it will return something like sub { $tobj->check($_[0]) }
524- return $tobj -> _compiled_type_constraint;
517+ return $tobj -> check($value );
525518 }
526519}
527520
0 commit comments