This stops us from allowing you to compose roles with has '+attr',
which latter fail when composed onto a class, by exploding earlier
(i.e. at the point which the attribute is added)
It seems like there is some duplicate functionality in Moose::Meta::Class'
process_attribute / add_attribute methods, possible candidate for later
refactoring?
Also see Moose::Manual::Delta for more details of, and workarounds
for, noteworthy changes.
+ [BUG FIXES]
+
+ * Fix has '+attr' in Roles to explode immediately, rather than when the role
+ is applied to a class.
+
1.03 Thu, May 06, 2010
[NEW FEATURES]
my $class = ref $_[0];
Moose->throw_error( "Cannot add a $class as an attribute to a role" );
}
+ elsif (!blessed($_[0]) && $_[0] =~ /^\+(.*)/) {
+ Moose->throw_error( "has '+attr' is not supported in roles" );
+ }
return $self->SUPER::add_attribute(@_);
}
} "or add new types to the union";
}
+{
+ package Role::With::PlusAttr;
+ use Moose::Role;
+
+ with 'Foo::Role';
+
+ ::throws_ok {
+ has '+bar' => ( is => 'ro' );
+ } qr/has '\+attr' is not supported in roles/,
+ "Test has '+attr' in roles explodes";
+}
+
done_testing;