Skip to content

Commit c8f752e

Browse files
revert the Sub::Defer changes again temporarily (see RT#119534, RT#120129)
1 parent bd8305e commit c8f752e

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

Changes

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
Revision history for MooseX-Types
22

33
{{$NEXT}}
4+
- reverted the is_Fo and to_Foo refactoring again temporarily to
5+
resolve issues with Sub::Defer
46

57
0.49 2016-12-23 00:12:12Z
68
- made the exported is_Foo and to_Foo subs much faster, especially for
7-
type constraints which can be inlined. (Dave Rolsky)
9+
type constraints which can be inlined. (Dave Rolsky) [reverted in
10+
0.50)
811

912
0.48 2016-12-07 01:15:14Z
1013
- reverted is_Foo and to_Foo refactoring [from 0.47] for now, so they
@@ -15,7 +18,7 @@ Revision history for MooseX-Types
1518
combined with MooseX::Types::Combine. (GH #1, Mark Fowler).
1619
- made the exported is_Foo and to_Foo subs much faster, especially for
1720
type constraints which can be inlined [reverted in 0.48,
18-
reimplemented in 0.49]
21+
reimplemented in 0.49, reverted in 0.50]
1922

2023
0.46 2015-08-16 00:43:46Z
2124
- make use of Sub::Exporter::ForMethods's new rebless option

lib/MooseX/Types.pm

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use MooseX::Types::Util qw( filter_tags );
1212
use MooseX::Types::UndefinedType;
1313
use MooseX::Types::CheckedUtilExports ();
1414
use Carp::Clan qw( ^MooseX::Types );
15-
use Sub::Defer qw( defer_sub );
1615
use Sub::Name;
1716
use Scalar::Util qw( reftype );
1817
use 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

488487
sub 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

513509
sub 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

Comments
 (0)