our $AUTHORITY = 'cpan:STEVAN';
use Package::DeprecationManager -deprecations => {
- 'coerce without coercion' => '1.08',
- 'pre-0.94 MetaRole API' => '0.94',
- 'alias or excludes' => '0.89',
- 'Role type' => '0.84',
- 'subtype without sugar' => '0.72',
- 'type without sugar' => '0.72',
- 'Moose::init_meta' => '0.56',
+ 'default is for Native Trait' => '1.14',
+ 'default default for Native Trait' => '1.14',
+ 'coerce without coercion' => '1.08',
+ 'pre-0.94 MetaRole API' => '0.94',
+ 'alias or excludes' => '0.89',
+ 'Role type' => '0.84',
+ 'subtype without sugar' => '0.72',
+ 'type without sugar' => '0.72',
+ 'Moose::init_meta' => '0.56',
},
-ignore => [
qw( Moose
package Moose::Meta::Attribute::Native::Trait;
use Moose::Role;
use Moose::Util::TypeConstraints;
+use Moose::Deprecated;
our $VERSION = '1.15';
$VERSION = eval $VERSION;
$self->_check_helper_type( $options, $name );
- $options->{is} = $self->_default_is
- if !exists $options->{is} && $self->can('_default_is');
+ if ( !exists $options->{is} && $self->can('_default_is') ) {
+ $options->{is} = $self->_default_is;
- $options->{default} = $self->_default_default
- if !exists $options->{default} && $self->can('_default_default');
+ Moose::Deprecated::deprecated(
+ feature => 'default is for Native Trait',
+ message =>
+ q{Allowing a native trait to automatically supply a value for "is" is deprecated}
+ );
+ }
+
+ if ( !exists $options->{default} && $self->can('_default_default') ) {
+ $options->{default} = $self->_default_default;
+
+ Moose::Deprecated::deprecated(
+ feature => 'default default for Native Trait',
+ message =>
+ 'Allowing a native trait to automatically supply a default is deprecated'
+ );
+ }
};
sub _check_helper_type {
--- /dev/null
+use strict;
+use warnings;
+
+use Test::More;
+
+use Test::Requires {
+ 'Test::Output' => '0.01',
+};
+
+{
+ package Role;
+
+ use Moose::Role;
+
+ sub thing { }
+}
+
+{
+ package Foo;
+
+ use Moose;
+
+ ::stderr_like{ has foo => (
+ traits => ['String'],
+ is => 'ro',
+ isa => 'Str',
+ );
+ }
+ qr/\QAllowing a native trait to automatically supply a default is deprecated/,
+ 'Not providing a default for native String trait warns';
+
+ ::stderr_like{ has bar => (
+ traits => ['String'],
+ isa => 'Str',
+ default => q{},
+ );
+ }
+ qr/\QAllowing a native trait to automatically supply a value for "is" is deprecated/,
+ 'Not providing a value for is with native String trait warns';
+
+ ::stderr_like{ with 'Role' =>
+ { excludes => ['thing'], alias => { thing => 'thing2' } };
+ }
+ qr/\QThe alias and excludes options for role application have been renamed -alias and -excludes/,
+ 'passing excludes or alias with a leading dash warns';
+ ::ok(
+ !Foo->meta->has_method('thing'),
+ 'thing method is excluded from role application'
+ );
+ ::ok(
+ Foo->meta->has_method('thing2'),
+ 'thing2 method is created as alias in role application'
+ );
+}
+
+done_testing;
+