use Try::Tiny;
use overload ();
-our $VERSION = '1.08';
+our $VERSION = '1.12';
our $AUTHORITY = 'cpan:STEVAN';
+use Moose::Deprecated;
use Moose::Meta::Method::Accessor;
use Moose::Meta::Method::Delegation;
use Moose::Util ();
# ...
-sub illegal_options_for_inheritance { }
+# method-generating options shouldn't be overridden
+sub illegal_options_for_inheritance {
+ qw(reader writer accessor clearer predicate)
+}
# NOTE/TODO
# This method *must* be able to handle
sub clone_and_inherit_options {
my ($self, %options) = @_;
- my %copy = %options;
-
# NOTE:
# we may want to extends a Class::MOP::Attribute
# in which case we need to be able to use the
? $self->illegal_options_for_inheritance
: ();
- my @found_illegal_options = grep { exists $options{$_} ? $_ : undef } @illegal_options;
+ my @found_illegal_options = grep { exists $options{$_} && exists $self->{$_} ? $_ : undef } @illegal_options;
(scalar @found_illegal_options == 0)
|| $self->throw_error("Illegal inherited options => (" . (join ', ' => @found_illegal_options) . ")", data => \%options);
unless ( $options->{type_constraint}->has_coercion ) {
my $type = $options->{type_constraint}->name;
- $class->throw_error("You cannot coerce an attribute ($name) unless its type ($type) has a coercion", data => $options);
+
+ Moose::Deprecated::deprecated(
+ feature => 'coerce without coercion',
+ message =>
+ "You cannot coerce an attribute ($name) unless its type ($type) has a coercion"
+ );
}
}
. "an accessor"
);
}
+ if (!$self->associated_class->has_method($accessor)
+ && $self->associated_class->has_package_symbol('&' . $accessor)) {
+ Carp::cluck(
+ "You are overwriting a locally defined function ($accessor) with "
+ . "an accessor"
+ );
+ }
$self->SUPER::_process_accessors(@_);
}
return $val unless $self->has_type_constraint;
$val = $self->type_constraint->coerce($val)
- if $self->should_coerce;
+ if $self->should_coerce && $self->type_constraint->has_coercion;
$self->verify_against_type_constraint($val, instance => $instance);