From: Dave Rolsky Date: Wed, 20 Jul 2011 15:12:58 +0000 (-0500) Subject: deprecate optimize_as X-Git-Tag: 2.0300~137 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7ec88c1526c32dd5c4045132b745687a1bd2d311;p=gitmo%2FMoose.git deprecate optimize_as --- diff --git a/Changes b/Changes index 83783e3..ab7a8c0 100644 --- a/Changes +++ b/Changes @@ -3,6 +3,12 @@ for, noteworthy changes. {{$NEXT}} + [DEPRECATIONS] + + * The optimize_as option for type constraints has been deprecated. Use the + inline_as option to provide inlining code instead. (Dave Rolsky) + + 2.0200 Mon, Jul 18, 2011 [OTHER] diff --git a/lib/Moose/Deprecated.pm b/lib/Moose/Deprecated.pm index c578436..1df1f05 100644 --- a/lib/Moose/Deprecated.pm +++ b/lib/Moose/Deprecated.pm @@ -4,9 +4,10 @@ use strict; use warnings; use Package::DeprecationManager 0.07 -deprecations => { - 'default is for Native Trait' => '1.14', - 'default default for Native Trait' => '1.14', - 'coerce without coercion' => '1.08', + 'optimized type constraint sub ref' => '2.0000', + 'default is for Native Trait' => '1.14', + 'default default for Native Trait' => '1.14', + 'coerce without coercion' => '1.08', }, -ignore => [qr/^(?:Class::MOP|Moose)(?:::)?/], ; diff --git a/lib/Moose/Meta/TypeConstraint.pm b/lib/Moose/Meta/TypeConstraint.pm index db0fbc0..6060726 100644 --- a/lib/Moose/Meta/TypeConstraint.pm +++ b/lib/Moose/Meta/TypeConstraint.pm @@ -118,6 +118,15 @@ sub new { my %args = ref $first ? %$first : $first ? ($first, @rest) : (); $args{name} = $args{name} ? "$args{name}" : "__ANON__"; + if ( $args{optimized} ) { + Moose::Deprecated::deprecated( + feature => 'optimized type constraint sub ref', + message => + 'Providing an optimized subroutine ref for type constraints is deprecated.' + . ' Use the inlining feature (inline_as) instead.' + ); + } + my $self = $class->_new(%args); $self->compile_type_constraint() unless $self->_has_compiled_type_constraint; diff --git a/t/basics/deprecations.t b/t/basics/deprecations.t index 9a8a4c0..2466f6f 100644 --- a/t/basics/deprecations.t +++ b/t/basics/deprecations.t @@ -157,5 +157,20 @@ use Test::Requires { sub _build_foo { q{} } } +{ + use Moose::Util::TypeConstraints; + + is( + exception { + stderr_like { + subtype 'Frubble', as 'Str', optimize_as sub { }; + } + qr/\QProviding an optimized subroutine ref for type constraints is deprecated./, + 'Providing an optimize_as sub is deprecated'; + }, + undef + ); +} + done_testing;